Convert Character to Integer tnat can be used for Sum-function

Hello!
I am new to Matlab and have a problebly simple question.
I have a cell of Characters that I want to convert to numbers(I guess integers) that can be used for a sum function. How do I convert these characters?
For example I have the characters '7952.11' and '7922.01' that need to be converted and summerized.
I have tried X=str2double('7952.11');
However, I get the display X = 7.952110000000000e+03 and not X = 7952.11 as I want to. How can I overcome this problem?

 채택된 답변

Matt J
Matt J 2022년 5월 12일
편집: Matt J 2022년 5월 12일
There is no problem. Both X = 7.952110000000000e+03 and X = 7952.11 are the same number.
However if you prefer the latter display style, use format longG
format longG
X=str2double('7952.11')
X =
7952.11

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2022년 5월 12일

댓글:

2022년 5월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by