How do I extract the rows of a matrix when I have the row numbers stored in another vector?
    1 回表示 (過去 30 日間)
  
       古いコメントを表示
    
I have a 102x3 matrix, I need to extract all the rows that have the number 1 in the first column and put them in a separate matrix.
Ive tried using the find function to produce a vector listing all the row numbers of when this occurs however I am not sure how to use this to extract the whole rows from the large matrix.
0 件のコメント
採用された回答
  Wayne King
    
      
 2013 年 4 月 28 日
        
      編集済み: Wayne King
    
      
 2013 年 4 月 28 日
  
         A = randi([0 4],102,3);
   idx = find(A(:,1) == 1);
   B = A(idx,:);
Another way:
   B = A(A(:,1)==1,:);
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Shifting and Sorting Matrices についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

