Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read binary file in one block rather than using a loop in matlab

I have this file which is a series of x, y, z coordinates of over 34 million particles and I am reading them in as follows:

parfor i = 1:Ntot
 x0(i,1)=fread(fid, 1, 'real*8')';
 y0(i,1)=fread(fid, 1, 'real*8')';
 z0(i,1)=fread(fid, 1, 'real*8')';
end

Is there a way to read this in without doing a loop? It would greatly speed up the read in. I just want three vectors with x,y,z. I just want to speed up the read in process. Thanks. Other suggestions welcomed.

like image 709
Griff Avatar asked Dec 29 '25 17:12

Griff


1 Answers

I do not have a machine with Matlab and I don't have your file to test either but I think coordinates = fread (fid, [3, Ntot], 'real*8') should work fine.

like image 74
carandraug Avatar answered Jan 01 '26 09:01

carandraug



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!