Clear Filters
Clear Filters

Is there any function that similar like CELLFUN, for a TABLE Dataype

25 views (last 30 days)
Following my earlier thread "Modified the CELL'S column number into words", I had to change the data representation from CELL into TABLE type. However, this new changes make part of the code not working. In the earlier version of the code, the following lines were used to access parts of the cells that satisfying the three conditions.
valid = find(cellfun('isclass', at.PatData(:, 1), 'char') & ...
cellfun('isclass', at.PatData(:, 2), 'char') & ...
cellfun('isclass', at.PatData(:, 3), 'char'));
Since, the data was represent in a new form,TABLE type. Obviously, the above line is not working. Thus, I plan to change it accordingly. However, I am unable to find any build in function that similar to CELLFUN, for a table datatype. I do not know whether I use the wrong keyword or such function is in fact not available at all.
The complete code and mat file are attached together in this thread.
Thanks in advance

Accepted Answer

balandong
balandong on 2 Aug 2017
Dear all
Turn out, using TABLE type is more flexible and easier. The above problem was solved using
valid = find((at.sub.Condition == cond_Cond) & (at.sub.Shiftday == cond_SD) ); % work
Valindex = valid((strcmp(at.sub.ID(valid,1),cond_Sbj)));
For those new to table, please see Table.
Problem SOLVED

More Answers (1)

Peter Perkins
Peter Perkins on 27 Jul 2017
It's not clear what you code is doing, or what you're using the output for. It appears that your code is finding rows of an Nx3 cell array in which all three cells contains a char array. Also just guessing again, but it looks like maybe you are converting that cell array into a table using cell2table, and because all the columns contain both chars and numbers, the result is a table all of whose variables are cell arrays containing both chars and numbers. And then whatever you are trying to do with varfun errors because hardly anything, including unique, does anything useful on a cell array that contains both numbers and chars.
I think you need to step back and rethink whatever you are doing.
  1 Comment
balandong
balandong on 29 Jul 2017
Hi Peter, Thanks for the reply, do you manage to check the full code attached together in this thread. I include some comment in the code.

Sign in to comment.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!