How to filter rows with respect to specific entry?

3 visualizzazioni (ultimi 30 giorni)
I have thousands of rows and I want to filter those rows in which the entry at third position is three
For example
A=[1 2 3 4 5 6 7 8 9;0 1 2 3 4 5 6 7 8 9 10;5 6 3 2 1 4 7 8 9];
I want the resulting matrix
AA=[1 2 3 4 5 6 7 8 9;5 6 3 2 1 4 7 8 9]
Thanks
  1 Commento
dpb
dpb il 10 Mar 2018
>> A=[1 2 3 4 5 6 7 8 9;0 1 2 3 4 5 6 7 8 9 10;5 6 3 2 1 4 7 8 9];
Dimensions of matrices being concatenated are not consistent.
>>

Accedi per commentare.

Risposta accettata

dpb
dpb il 10 Mar 2018
>> A=[1 2 3 4 5;0 1 2 3 4;5 6 3 2 1];
>> A(A(:,3)==3,:)
ans =
1 2 3 4 5
5 6 3 2 1
>>

Più risposte (0)

Categorie

Scopri di più su Resizing and Reshaping Matrices 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!

Translated by