# Import data doesn't import some of the values

3 views (last 30 days)
Emanuele Giacomuzzo on 23 Nov 2020
Edited: Stephen Cobeldick on 27 Nov 2020
When I try to import a matrix into MatLab from a text file, it doesn't import some of the values. An example of values that is not imported is 2.134282. An example of values is imported is 0.00277.

#### 1 Comment

Emanuele Giacomuzzo on 23 Nov 2020
The file that I have attached contains the matrix that I can't import.

Ameer Hamza on 23 Nov 2020
Have you tried readmatrix()? It seems to import the value correctly
format long
x = M(26, 35)
Result
>> x
x =
2.134282000000000

VBBV on 23 Nov 2020
Edited: VBBV on 23 Nov 2020

Stephen Cobeldick on 23 Nov 2020
"but it rounds the last 3 decimal places to nearest integer"
I doubt that.
Most likely you are confusing how data are displayed with the data values stored in memory.
"It shows as 2.1343 instead of 2.134282."
Yes, because the default display format prints numeric values with four digits after the decimal point:
You can change the format to something that displays more digits if you want. Of course changing how values are displayed makes no difference to their values in memory.
VBBV on 27 Nov 2020
If the default format is 4 decimal places it should have shown 2.1342. But it doesn't.
Stephen Cobeldick on 27 Nov 2020
"If the default format is 4 decimal places it should have shown 2.1342. But it doesn't."
In science and mathematics stating that a value is shown to X significant figures or decimal places means that the value is rounded to the specified digit/order (not truncated as suggest) as this reduces the relative error. MATLAB correctly displays 2.134282 with four digits after the decimal point:
format short
2.134282
ans = 2.1343
For example, the value 1.000099999 shown with four figures after the decimal point will be 1.0001:
1.000099999
ans = 1.0001
MATLAB is displaying the values correctly.