Retrieving (all) information from a cell array when meeting a predefined condition?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Aleksandar
am 5 Mai 2015
Beantwortet: Aleksandar
am 5 Mai 2015
I have a cell array a={'100025','31-Jul-07','C';'100025','31-Aug-07','D';'020657','31-May-08','E';'020657','31-Aug-09','A'}; etc... a =
'100025' '31-Jul-07' 'C'
'100025' '31-Aug-07' 'D'
'020657' '31-May-08' 'E'
'020657' '31-Aug-09' 'A'
How can I retrieve only information (all rows and columns) for '020657' ? In this case I want to retrive only rows 3 and 4. I tried something from instructions (but that is to find indices): refstring='020657'; index1= find(strcmp(a,refstring)); %I get indices 3 and 4 index2=strcmp(a,refstring); %I get ones for 3 and 4 (other zeros...) but that is not what I want...
0 Kommentare
Akzeptierte Antwort
James Tursa
am 5 Mai 2015
Bearbeitet: James Tursa
am 5 Mai 2015
Using logical indexing:
a(strcmp(a(:,1),refstring),:)
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Cell Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!