tags:

views:

227

answers:

1

hi let's assume i have the following in matlab

             h = [0,0,0,1;
                  1,1,1,1];

now how can i print all the values of the first subarray, i.e. 0,0,0,1

or for example the second subarray 1,1,1,1. thanks !

+3  A: 

You can access just the first row of your matrix by doing

   firstRow = h(1,:)

Similarly, you could access just the third column by

   thirdColumn = h(:,3)

I suggest you look into the MATLAB help under "Matrix Indexing" as this is really basic stuff (and there's a lot of other nifty things you can do to access a subset of a matrix)

For printing, you can omit the final ;, or look into functions display and fprintf.

Kena

related questions