フィルターのクリア

How to get readmatrix to keep data to a certain amount of decimal points?

33 ビュー (過去 30 日間)
Steven
Steven 2023 年 3 月 7 日
回答済み: Arka 2023 年 3 月 7 日
I am using readmatrix to pull data from a .csv that data points such as 2022.375. However, my readmatrix for the file turns it into 1.0e+03 * 2.0224. How can I make readmatrix keep the accuracy I need it to?
  1 件のコメント
Stephen23
Stephen23 2023 年 3 月 7 日
"However, my readmatrix for the file turns it into 1.0e+03 * 2.0224."
No, READMATRIX does not "turn" your data into anything like that. You are confusing how numeric data are displayed with what data are stored in memory. Not the same things at all (although they are related to each other). READMATRIX imports all of your data correctly and it is all stored correctly. How it is displayed depends on your FORMAT settings, which by default are SHORT, i.e. four digits after the decimal point. But you can change that.
"How can I make readmatrix keep the accuracy I need it to?"
It already does.
If you want to change how numeric data are displayed then change the FORMAT, e.g. use LONG G.

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

回答 (1 件)

Arka
Arka 2023 年 3 月 7 日
Hi,
1.0e+03 * 2.0224 is just another way of representing 2022.375. The data is being stored in the format it was read from the CSV in, and it is being displayed in the format that we have specified.
In MATLAB, there are multiple ways of displaying values. 1.0e+03 * 2.0224 is in short e format, and 2022.375 is in long format.
To know more about the format command, please refer to the MathWorks documentation below:

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by