operator '==' not supported for operands of type 'cell'
642 views (last 30 days)
Show older comments
While there are some useful answers to this type of question, a lot of them are too advanced for me to understand/use as a beginning MATLAB student. I am trying to loop through rows of a table to find instances in which in a particular index is equal to something. Here is a picture of what my table looks like:
and I am interested in comparing when a subject has responded true or false to a certain verb ('smashed' is one of 3). My idea for doing this would be to make a for loop such as the following:
smashedFalseCounter = 0;
for i = 1:height(myTable)
if myTable.verb(i) == 'smashed'
if expTable2.response(i) == false
smashedFalseCounter = smashedFalseCounter + 1;
end
end
end
And I get the following error message:
1 Comment
Answers (1)
madhan ravi
on 4 Jun 2020
ismember(myTable.verb(i), 'smashed')
1 Comment
madhan ravi
on 4 Jun 2020
Edited: madhan ravi
on 12 Oct 2020
And by the way you don’t need a loop.
Counts = nnz(ismember(myTable.verb(myTable.Response == true), 'smashed'))
See Also
Categories
Find more on Logical 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!