Matrices and arrays

To create an array with four elements per row, separate elements with commas (,) or spaces

a = [1 2 3 4]

MATLAB will execute the above statement and return the following results:

a = 1×4
     1     2     3     4

#Create a matrix with multiple rows

a = [1 3 5; 2 4 6; 7 8 10]

a = 3×3
     1     3     5
     2     4     6
     7     8    10

#5×1 column vector of zeros

z = zeros(5,1)

z = 5×1
     0
     0
     0
     0
     0
Comments