[ Team LiB ] Previous Section Next Section

M1.6 More Matrix Stuff

A matrix can be constructed from two or more vectors. If we wish to create a matrix v which consists of two columns, the first column containing the vector x (in column form) and the second column containing the vector z (in column form), we can use the following (where x and z are previously generated row vectors):


» v = [x',z']
v =
     1     5
     3    10
     5    15
     7    20
     9    25
    11    30

If we wished to look at the first column of v, we could use (where : indicates all rows, while the 1 indicates the first column)


» v(:,1)
ans =
     1
     3
     5
     7
     9
    11

If we wished to look at the second column of v, we could use


» v(:,2)
ans =
     5
    10
    15
    20
    25
    30

And we can construct the same plot as before by using the following plot command ('--' gives a dashed line):


» plot(v(:,1),v(:,2),'--')
    [ Team LiB ] Previous Section Next Section