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 件のコメント

Cedric
Cedric 2017 年 10 月 14 日
That shouldn't be the case. Can you provide a small example?

サインインしてコメントする。

 採用された回答

Cedric
Cedric 2017 年 10 月 14 日
編集済み: Cedric 2017 年 10 月 14 日

0 投票

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 件のコメント

ahmed taha
ahmed taha 2017 年 10 月 20 日
exactly , thanks so much
Cedric
Cedric 2017 年 10 月 20 日
My pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics and Optimization についてさらに検索

質問済み:

2017 年 10 月 14 日

コメント済み:

2017 年 10 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by