Increasing speed to perform binary read/write operations

1 view (last 30 days)
Hello everyone. I have a big binary file with a ascii header. In binary part I have a data which I need to change, smooth etc. Read part is looks like:
fid1=fopen(path,'rb','l');
for ii=1:ramp
skbytes=begbytes+skip+(ii-1)*skip+(ix-1)*nx*ncol+(iy-1)*nx;
fseek(fid1,skbytes,'bof');
ax=fread(fid1,[1 1],sh);
aax=double(ax);
yiv(ii,1)=aax;
end
fclose(fid1);
The writing part is the next:
fid=fopen(path1,'r+','l');
for kk=1:ramp
skbytes=begbytes+skip+(ix-1)*ncol*nx+(iy-1)*nx+(kk-1)*skip;
fseek(fid,skbytes,'bof');
fwrite(fid,smy(kk,1),sh);
end
clear kk;
fclose(fid);
The problem is I have 128x128 numbers of these curves. And it is required 3 hours to perform all calculations.
I will be thankful for any idea or help with this.
  1 Comment
Dima Lotnik
Dima Lotnik on 20 Nov 2014
I also tried to use memmapfile function. But the time to create a single curve is almost the same. The code I use is below:
m = memmapfile('path','Offset',beg,'Format',{'int16',[ncol nrow],'mj'},'Repeat',ramp+1, 'Writable', true);
for ii=1:ncol
tic;
for jj=1:nrow
for kk=1:ramp
iv(kk,1)=m.data(kk+1).mj(ii,jj);
end
end
toc;
end

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!