rows extraction in matrix depending on a column value
    1 visualizzazione (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
I have a 50x50 matrix and n that the last row has 0,1,2 at different locations ie., 0 n 10 rows,1 n 20 rows ad 2 in 20 rows, so depending on the column value how can i extract all rows containing 0 at 50th column and save them in to a single variable
2 Commenti
  Sean de Wolski
      
      
 il 28 Giu 2013
				A small example of your matrix and expected results would make this much easier to grasp.
Risposta accettata
  Image Analyst
      
      
 il 28 Giu 2013
        Try this:
% Generate sample data
A=[...
1 2 3 0; 
1 2 5 0;
5 8 6 1;
6 8 7 0;
5 4 7 2;
6 5 8 0]
% Get last column
lastColumn = A(:, end);
% Get zeros
A0 = A(lastColumn == 0, :)
% Get zeros
A1 = A(lastColumn == 1, :)
% Get zeros
A2 = A(lastColumn == 2, :)
In the command window:
A =
     1     2     3     0
     1     2     5     0
     5     8     6     1
     6     8     7     0
     5     4     7     2
     6     5     8     0
A0 =
     1     2     3     0
     1     2     5     0
     6     8     7     0
     6     5     8     0
A1 =
     5     8     6     1
A2 =
     5     4     7     2
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Spline Postprocessing in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



