0.5 Soft Introduction to MATLAB 31y =
1
2
3
4To see the dimension ofxandyvariables, type
whos % provides information on existing variablesto which MATLAB responds
Name Size Bytes Class
x 1x4 32 double array
y 4x1 32 double array
Grand total is 8 elements using 64 bytesNotice that a vector is thought of as a matrix; for instance, vectorxis a matrix of one row and four
columns. Another way to express the column vectoryis the following, where each of the row terms
is separated by a semicolon (;)
y = [1;2;3;4] % another way to write a columnTo give as before:
y =
1
2
3
4MATLAB does not allow arguments of vectors or matrices to be zero or negative. For instance, if we
want the first entry of the vectorywe need to type
y(1) % first entry of vector ygiving as output
ans =
1If we type
y(0)it will give us an error, to which we get the following warning:
??? Subscript indices must either be real positive integers or logicals.MATLAB also has a peculiar way to provide information in a vector, for instance:
y(1:3) % first to third entry of column vector y