1234.5 instead of 1.2345e+03
7 ビュー (過去 30 日間)
古いコメントを表示
When I read a variable from Excel with value say, 1234.5, Matlab reads in as 1.2345e+03. Instead I want the original format to be preserved (ie., it should stay as it is say, 1234.5 in this example). I have tried "format short g" etc, but these deal with number of digits after the decimal. How can I set the correct format? Thanks, Ganesh
1 件のコメント
Jan
2012 年 7 月 7 日
Internally 1234.5 and 1.2345e+03 are the same numbers. The different notation concerns only the output to the command windows. Therefore it is necessary that you post more relevant details of your problem.
回答 (3 件)
the cyclist
2012 年 7 月 6 日
編集済み: the cyclist
2012 年 7 月 6 日
It depends on the context of where you want this number displayed, but here is one way to show this number the way you want:
x = 1234.5;
sprintf('%5.1f',x)
0 件のコメント
Ganesh
2012 年 7 月 6 日
2 件のコメント
the cyclist
2012 年 7 月 6 日
In MATLAB-speak, the "format" generally refers to how the variables are displayed, not to how they are stored internally, or used for computation.
Can you confirm that your variable xdata and ydata are being imported as numeric arrays, and not as text? That could be the problem. Are you able to post a small snippet of self-contained code that exhibits the problem?
Ganesh
2012 年 7 月 6 日
1 件のコメント
Walter Roberson
2012 年 7 月 6 日
What evidence do you see that the fitcurvedemo call is not working?
Does the issue only affect the xdata, or only affect the ydata ? For example if you were to divide the ydata by 10 so that it remained less than 1000, does that work?
参考
カテゴリ
Help Center および File Exchange で Other Formats についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!