On Wednesday, November 27, 2013 6:19:38 PM UTC+13, Karrar Jaffar wrote: > I have a single filename.mat file which contains 1500 sub sim_i.mat (for i=1,.....1500) files which have the data that I want. I just have urgent questions > > > > 1) How to combine or merge the sub .mat files into a single .mat file containing all the data in matrix form? > > > > 2) How can I load the sub_i .mat files in the loops once the filename.mat is loaded in the matlab?
It is very bad practice to do this sort of thing in a panic. You will almost inevitably stuff it up. You need to back off and take several deep breaths, then approach it calmly and logically.
First of all, your Question 2 is actually Step 1. You can do this in a loop: for ifile=1:nfiles matfile=[pth 'sub_' num2str(ifile)]; s(ifile)=load(matfile); end
Now your Question 1 is Step 2: save([pth 'allmyfiles'],'s')
where pth is something like: 'c:\PathToMyMatfiles\'