basic math operations with numbers stored in cell arrays ?

1 view (last 30 days)
uitables are cell arrays and i can't do basic math with the data i get from the uitable , i tried cell2mat but it just concatenates all the numbers together as if they were strings and the division of a column by another gives wrong results

Accepted Answer

Cedric Wannaz
Cedric Wannaz on 14 Oct 2017
Edited: Cedric Wannaz on 14 Oct 2017
You probably have strings in the table and not numbers. If so, you should use STR2DOUBLE instead of CELL2MAT. It can operate on cell arrays and it outputs a numeric array.
>> cell2mat( {'12', '34'; '54', '32'} ) % This is probably what happens.
ans =
2×4 char array
>> str2double( {'12', '34'; '54', '32'} ) % This is what you should do instead.
ans =
12 34
54 32

More Answers (0)


Find more on Mathematics and Optimization 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!