0% found this document useful (0 votes)
9 views1 page

MATLAB Cheat Sheet Scalars Vectors Matrices

Uploaded by

SFSM
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

MATLAB Cheat Sheet Scalars Vectors Matrices

Uploaded by

SFSM
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Scalars, Vectors, and Matrices in MATLAB: What’s the Difference?

a MATLAB Cheat Sheet by SPARTAN PROFESSOR


SCALARS

Description: A scalar is a two-dimensional array that has a size of 1-by-1.

Useful Functions: isscalar(S) returns logical 1 (true) if S is a 1-by-1 scalar, and logical 0 (false) otherwise.

VECTORS

Description: A vector is a two-dimensional array that has a size of 1-by- n or m-by-1, where m and n are
nonnegative integers.

Useful Functions: isvector(A) returns logical 1 (true) if A is a vector. Otherwise, it returns logical 0 (false).
isrow(A) returns logical 1 (true) if size(A) returns [1 n] with a nonnegative integer value n, and
logical 0 (false) otherwise.
iscolumn(A) returns logical 1 (true) if size(A) returns [m 1] with a nonnegative integer value m,
and logical 0 (false) otherwise.

MATRICES

Description: A matrix is a two-dimensional array that has a size of m-by- n, where m and n are nonnegative
integers.

Useful Functions: ismatrix(A) returns logical 1 (true) if A is a matrix. Otherwise, it returns logical 0 (false).

SIZE AND DIMENSIONS

Useful Functions: ndims(A) returns the number of dimensions in the array A. The number of dimensions is
always greater than or equal to 2.
size(A) returns a row vector whose elements are the lengths of the corresponding dimensions
of A.

EXAMPLES
isscalar(A)

isvector(A)

iscolumn(A)

ismatrix(A)
ndims(A)

isrow(A)
size(A)

Input Output
1 2 3
A = [1,2,3;4,5,6;7,8,9] 4 5 6 3 3 2 0 0 0 0 1
7 8 9
A = [10,11,12] 10 11 12 1 3 2 0 1 1 0 1
13
A = [13;14;15] 14 3 1 2 0 1 0 1 1
15
A = 16 16 1 1 2 1 1 1 1 1

Spartan Professor LLC


spartanprofessor.com

You might also like