Find index for mx1 cell with specific string
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ivy Chen
am 29 Jun. 2018
Kommentiert: Ivy Chen
am 2 Jul. 2018
I have a mx1 cell in A table as Scenario column. I want to find the index matching the string 'Scenario #' using following:
Scenario_list=A.Scenario(Scenario==['Scenario 20']);
Received a "Error using == Matrix dimensions must agree." error message.
0 Kommentare
Akzeptierte Antwort
Stephen23
am 29 Jun. 2018
Bearbeitet: Stephen23
am 29 Jun. 2018
For comparing a cell array of char vectors and a char vector you have to use strcmp, or strcmpi, or strncmp, etc:
idx = strcmp(A.Scenario,'Scenario 20')
The == operator only works for string arrays:
Do not confuse character vectors or character arrays with string arrays:
Siehe auch
Kategorien
Mehr zu Characters and Strings 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!