Reputation: 147
the following is part of my code, when I run it, I find that data and data1 is only file B5.m, I would like to save all iterations (Example, B11.m to B55.m). finally, I want to add B11 from first folder with B11 from other folder and save it in new folder.
for i = 1:5
for j=1:5
name=['B',num2str(i),num2str(i),'.m'];
name1=['B',num2str(j),num2str(i),'.m'];
data=load([p,name]);
data1=load([w,name1]);
end
end
Upvotes: 0
Views: 3158
Reputation: 26069
Try to input the entire data workspace that you load into a struct
. something like:
c=0;
for i = 1:5
for j=1:5
c=c+1;
name=['B',num2str(i),num2str(i),'.m'];
name1=['B',num2str(j),num2str(i),'.m'];
data=load([p,name]);
data1=load([w,name1]);
s=struct(c,data);
s1=struct(c,data1);
end
end
Upvotes: 1
Reputation: 3194
Try :
save([p, name], 'data', '-ASCII')
save([w, name], 'data1', '-ASCII')
Upvotes: 1