开发者

matlab - print subarray of two dimensional array

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 !


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜