How can I use dlmread to input data as single precision?

3 Ansichten (letzte 30 Tage)
Baoqiang
Baoqiang am 9 Feb. 2011
I am using dlmread to get input data and found that the return matrix is always double precision which is too big for the memory on my machine. I'm wonder anyhow I could make the reading use just single precision. Here is what I'm doing:
mat = dlmread('a.txt');

Akzeptierte Antwort

Todd Flanagan
Todd Flanagan am 9 Feb. 2011
I think you want to use textscan. That will allow you to specify the input format. The %f32 format will import as single precision. For example:
>> f = fopen('data.txt');
>> textscan(f, '%f32')
ans =
[3x1 single]
  1 Kommentar
Jan
Jan am 9 Feb. 2011
You can create a copy of DLMREAD.M and insert this format specifier in the TEXTSCAN call. Then you have a fully featured DLMREAD with SIGNLE output.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Large Files and Big Data finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by