Azzera filtri
Azzera filtri

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

28 visualizzazioni (ultimi 30 giorni)
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 Commento
Stephen23
Stephen23 il 7 Mar 2023
"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.

Accedi per commentare.

Risposte (1)

Arka
Arka il 7 Mar 2023
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:

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by