Hello everyone and thanks a lot in advance for your assistance.
Please allow me to introduce you to the problem:
I have an excel file where in the first column there are different students' names. Also, in the second and third column, there are the names of their hometowns and their class level, respectively.
For example:
George London Class B1
George Liverpoool Class B2
Andrew London Class C1
... ... ...
Mairy London Class C2
All these data were imported into Matlab via readable command (because with the xlsread I was getting NAN values).
Now what I need to do is a formula which will find all those students that live in 1 specific town. Let that town be London.
Next, from the previously created table, I need to find those students which belong to Class B1, B2, C1 and C2 respectively. Let B2 to be selected class for this example:
My code is as below:
Alldata = readtable('alldata.xlsx'); Hometown = alldata(:, 14); ==> The hometowns are in column 14.
Class = alldata(:, 13); ==> The classes are in column 13.
a = 'London';
b = 'Class B2';
Result1 = find(alldata.HOMETOWNS == 'a');
Relust 2 = find(alldata.CLASSES == 'b');
FinalTable = table(Relult1, Relust2);
I though that this should worked fine but I get the error: Undefined operator '==' for input arguments of type 'table'.
I also changed parenthesis to braces, the table(s) to cell arrays but nothing worked for me. Unfortunately, I have not too much experience with Matlab sofware, and hence, you are kindly requested to help me with this one cause I really don't have a clue about what is wrong.
I look forward to your reply.
Thanks a lot in advance guys,
Nick A.
1 Comment
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/399133-help-find-all-rows-of-a-table-which-meet-a-specific-condition#comment_820643
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/399133-help-find-all-rows-of-a-table-which-meet-a-specific-condition#comment_820643
Sign in to comment.