提取矩阵中的多列

比如一个矩阵有10列,怎样才能提取其中的3 4 5 8 9列呢?

ans:

 

 
>> A = randn(2,10)
A =
  Columns 1 through 8
   -0.4326    0.1253   -1.1465    1.1892    0.3273   -0.1867   -0.5883   -0.1364
   -1.6656    0.2877    1.1909   -0.0376    0.1746    0.7258    2.1832    0.1139
  Columns 9 through 10
    1.0668   -0.0956
    0.0593   -0.8323

 

>> A(:,[3:5,8,9])
ans =
   -1.1465    1.1892    0.3273   -0.1364    1.0668
    1.1909   -0.0376    0.1746    0.1139    0.0593

 

 

 

posted on 2012-10-15 17:04  风也无踪  阅读(166)  评论(0编辑  收藏  举报

导航