String comparison in table
11 views (last 30 days)
Show older comments
t = table({'1', '2'; '2', '3'; '2', '3'; '4', '5'}, [1; 2; 1; 2], 'VariableNames', {'Multico', 'value'})
tochange = strcmp(t.Multico(1, :), '2')
Expected output:
tochange =
1×2 logical array
0 1 1
Obtained output:
tochange =
1×2 logical array
0 1
I'd like to know why the expected output is not obtained.
Any suggestions on how to obtain the expected output?
1 Comment
Answers (1)
AKARSH KUMAR
on 24 Jun 2020
The reason is you are not comparing a single value but multiple values in this case two values of the table.
Like in your case t.Multico row 1 (total 2 elements) to string '2' thats why got only two logical outputs
0 Comments
See Also
Categories
Find more on Cell Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!