readmatrix is truncating and moving decimal

36 ビュー (過去 30 日間)
Tate Anderson
Tate Anderson 2020 年 6 月 17 日
コメント済み: Tate Anderson 2020 年 6 月 17 日
I am trying to read in values from an excel file using readmatrix. However when I do, it is truncating the values to 4 decimal places and moving the decimal to the left by 5. I've included some of the values I am reading in and the output values.
expData = readmatrix(filepath, 'Range', [row column]);
Expected:
33972.45132 39866.2488 41830.75072 37335.1956 49199.85501
1113.630062 1113.391926 1117.544912 762.7461789 772.5554815
519.7667948 908.574646 912.5042935 1453.894848 3646.179932
616.3827322 418.8647381 557.0445367 490.6243073 486.6413401
3063.321961 3744.258294 3665.579968 2410.484524 2691.052388
Result:
0.3397 0.3987 0.4183 0.3734 0.4920
0.0111 0.0111 0.0112 0.0076 0.0077
0.0052 0.0091 0.0091 0.0145 0.0365
0.0062 0.0042 0.0056 0.0049 0.0049
0.0306 0.0374 0.0367 0.0241 0.0269

採用された回答

madhan ravi
madhan ravi 2020 年 6 月 17 日
format longg % at the beginning
  1 件のコメント
Tate Anderson
Tate Anderson 2020 年 6 月 17 日
Yep that did it, thanks.

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

その他の回答 (1 件)

David Hill
David Hill 2020 年 6 月 17 日
Are you sure there is not a times 1e5 somewhere before the matrix is displayed. The numbers are likely the same but the format is different. Look at format function, try:
format shortG;
  1 件のコメント
Tate Anderson
Tate Anderson 2020 年 6 月 17 日
Thanks for the info, I ended up using format longg as madhan suggested.

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

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by