Select rows given a condition
131 ビュー (過去 30 日間)
古いコメントを表示
I have a big- cell variable and I want to select it, considering the first row. So for instance if I have
A:
1997 FD 89
1997 GD 65
1999 FDK 87
2010 UY 123
I would like to get
B:
1997 FD 89
1997 GD 65
I tried to use the '==1997' function but it is not working because the input is a cell. An when I use 'isequal' I get B but it's a '0x0 cell' variable. Can anyone help me? Thanks a lot!
0 件のコメント
採用された回答
Titus Edelhofer
2014 年 6 月 24 日
Hi Maria,
you need to convert the first column into a vector
firstColumn = cell2mat(A(:,1));
rows1997 = A(firstColumn==1997, :);
Titus
その他の回答 (2 件)
Reda
2023 年 11 月 10 日
Dear sir,
I have a file name(metadat) which have 3 column and no of rows. My question is how to select all rows from the file with specific condition such as PP=0. I try allot of salutions but i didnt get the wright one. Thanks alot
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!