basic math operations with numbers stored in cell arrays ?

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

1 comentario

Cedric
Cedric el 14 de Oct. de 2017
That shouldn't be the case. Can you provide a small example?

Iniciar sesión para comentar.

 Respuesta aceptada

Cedric
Cedric el 14 de Oct. de 2017
Editada: Cedric el 14 de Oct. de 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
'1234'
'5432'
>> str2double( {'12', '34'; '54', '32'} ) % This is what you should do instead.
ans =
12 34
54 32

2 comentarios

exactly , thanks so much
Cedric
Cedric el 20 de Oct. de 2017
My pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Mathematics and Optimization en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 14 de Oct. de 2017

Comentada:

el 20 de Oct. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by