MATLAB - extracting rows of a matrix

后端 未结 5 846
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 14:26

a = [1 2; 3 4; 5 6] I want to extract the first and third row of a, so I have x = [1; 3] (indices of rows).

a(x)

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 14:58

    Like this: a([1,3],:)

    The comma separates the dimensions, : means "entire range", and square brackets make a list.

提交回复
热议问题