basic math operations with numbers stored in cell arrays ?

조회 수: 2 (최근 30일)
ahmed taha
ahmed taha 2017년 10월 14일
댓글: Cedric 2017년 10월 20일
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일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by