Sunday, 31 July 2016

MATLAB Programming 41 - Some vector operations

A vector is a one-dimensional array of numbers. MATLAB allows creating two types of vectors:

Row vectors
Column vectors

Row Vectors


Row vectors are created by enclosing the set of elements in square brackets, using space or comma to delimit the elements.

r = [7 8 9 10 11]

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

r =
Columns 1 through 4
7 8 9 10
Column 5
11

Column Vectors


Column vectors are created by enclosing the set of elements in square brackets, using semicolon to delimit the elements.

c = [7; 8; 9; 10; 11]

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

c =
7
8
9
10
11


No comments:

Post a Comment