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