How do I extract a row of data from a cell array based on a string?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dave
am 25 Mär. 2015
Beantwortet: Dave
am 26 Mär. 2015
I know there are similar questions like that and have reviewed most, but don't quite have it figured out yet. As an example I have a file containing information similar to below: 07/03/2010 07:15 AM 'Run' 'Race' 4 'Mile' 10/24/2010 12:00 PM 'Run' 'Hill' 4 'Mile' 11/14/2010 09:30 AM 'Run' 'Easy' 4 'Mile' I would like to extract all those rows that say are of type 'Hill'.
I've tried the following: hill_log = runlog1(cat(1,runlog1{:,4}) == 'Hill',:)
but get: Undefined function 'eq' for input arguments of type 'cell'. No doubt some basic nuance I'm missing.
Thanks
0 Kommentare
Akzeptierte Antwort
Sean de Wolski
am 25 Mär. 2015
cat(1,runlog1{:,4})
This is a cell so you can't compare it to a string. Instead use strcmp which works on cells and strings in this manner. Something like:
strcmp(cat(1,runlog1{:,4}),'Hill')
0 Kommentare
Weitere Antworten (1)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!