This code:
if (prefixTree(1,4).prefixTree2(:,2)=='2')
unique(prefixTree(1,4).prefixTree2(:,3))
end
returns this error:
Undefined function 'eq' for input arguments of type 'cell'.
Why?
The error implies that prefixTree(1,4).prefixTree2(:,2) is a cell array. You can access the individual elements of the second column with prefixTree(1,4).prefixTree2{:,2}. Also, the colon operator implies that there is more than one element in prefixTree(1,4).prefixTree2(:,2) but you're trying to do a scalar comparison. Lastly, you're comparing to a char ('2' as opposed to the number 2) and thus it would be best to use string functions. You can use strcmp to check each element of your cell:
prefixTree(1,4).prefixTree2 = {'1' '2';'3' '2'}; % Example data
strcmp(prefixTree(1,4).prefixTree2(:,2),'2')
Then use any or all to return a scalar for your if statement:
if all(strcmp(prefixTree(1,4).prefixTree2(:,2),'2'))
...
end
ifstatement to do?prefixTree(1,4).prefixTree2(:,2)looks like that it's a cell array, but your comparison doesn't make any sense at all. In plain English, what is yourifstatement doing? Take a step backward.prefixTree2(:,2)=='2'Matlab does not allow==for cell comparing, and also '2' would indicate that it is a String type? Try removing the ' ' and see what error it throws?strcmpthe string compare function that can be applied to indexed cell and compare its content with another string.