Out of memory error

2 views (last 30 days)
Najam us Saqib Fraz
Najam us Saqib Fraz on 29 Oct 2020
Answered: Walter Roberson on 29 Oct 2020
My data looks like this in the picture.I am using textscan to scan the data.But sometimes when the data is little bit larger it gives me error of less memory.If you see the picture each number is multiple decimal places which I do not need.Is there any way I can read the data having having three digits after the decmal.This will also remove the memory error.I am using Matlab 2015a.Thank You

Answers (1)

Walter Roberson
Walter Roberson on 29 Oct 2020
No. If you have any digits after the decimal point, then you are using floating point numbers, and floating point numbers do not use less storage if you have fewer decimal digits. The storage required for 3.0 is the same as for 3.5 is the same as for 3.25 is the same as 3.125 is the same as 3.14159265 -- 8 bytes in each case for double precision values.
What you can do is switch from using '%f' format to using '%f32' format. %f32 uses single precision values, which take only 4 bytes (32 bits) instead of 8 bytes (64 bits). This will use only half as much storage.


Community Treasure Hunt

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

Start Hunting!

Translated by