MATLAB: Saving variables in a single .mat file

.mat filesave

Hello,
I have 360 .mat files containing same variable in with different data (row vectors) each of size in(1×3800000) stored in them. They are of size 9.84GB (all 360 files).
Now I want to save them all in 1 .mat file as a matrix out(360×3800000).
How can I do it?

Best Answer

Try this code m=zeros(3800000,360); for k=1:360, eval(sprintf('load F*_%d.mat',k)); % F*=name of all your files .mat% eval(sprintf('y=F*_%d(:,1);',k)); disp(k); clear F* if k==1, m=y; else m=[m,y]; end end
save File m t %save the new file .mat
Related Question