Main Content

isvector

Determine whether input is vector

Description

example

TF = isvector(A)returns logical1(true) ifAis a vector. Otherwise, it returns logical0(false). A vector is a two-dimensional array that has a size of 1-by-N or N-by-1, where N is a nonnegative integer.

Examples

collapse all

Create a 2-by-2 matrix. Determine whether it is a vector.

A = [1 2; 3 4]; TF = isvector(A)
TF =logical0

Check whether the first column of the matrix is a vector.

TF = isvector(A(:,1))
TF =logical1

Check whether the first row of the matrix is a vector.

TF = isvector(A(1,:))
TF =logical1

Create a scalar, which is a 1-by-1 array.

A = 5;

Determine whether the scalarAis also a vector.

TF = isvector(A)
TF =logical1

Create an array of characters. Determine whether it is a vector.

A ='Hello, World!'; TF = isvector(A)
TF =logical1

Check the dimension ofAusingsize.Ais a 1-by-13 character vector.

sz = size(A)
sz =1×21 13

Now create a string scalar by enclosing a piece of text in double quotes.

A ="Hello, World!";

Check whether the scalarAis also a vector.

TF = isvector(A)
TF =logical1

Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array.

Algorithms

  • If the input arrayAhas more than two dimensions, thenisvector(A)always returns logical0(false). For example, an array of size 1-by-1-by-N is not a vector.

  • isvector(A)function does not have any special behavior for dimension lengths equal to 0. For example,isvector(A)returns logical1(true) if the size of A is 0-by-1. But,isvector(A)returns logical0(false) if the size of A is 0-by-3.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

HDL Code Generation
Generate Verilog and VHDL code for FPGA and ASIC designs using HDL Coder™.

Introduced before R2006a