run multiple inputs on an m-file to get multiple putputs in a loop

Thank yous o much for reading.. I want to put a .m file in a loop but with three other arrays sig and acs.and af=2.However size(sig)=8,74,80,10 and size(acs)=8,20,80,10. The m-file outputs recon and ws how can one store recon & ws for n=1:10. Sorry for the example:
for n=1:10 sig(n)=sig(:,:,:,n) acs(n)=acs(:,:,:,n) af=2 [recon,ws]=open(sig,acs,af) %m-file called open.m % save output recon(n) & ws(n) %?? end
Thank you so so much.

Answers (1)

I'm not sutre what you mean by "save recon(n)", perhaps this:
recon = zeros(1, 10);
ws = zeros(1, 10);
for n = 1:10
sig_n = sig(:,:,:,n);
acs_n = acs(:,:,:,n);
af = 2;
[recon(n), ws(n)] = open(sig_n, acs_n, af);
end

2 Comments

Thank you Jan.So this is what i did
recon=zeros(nc,yres,size(sg,3),nframe);
ws=zeros(nc,size(sg,3));
for n=1:size(sg,4)
sig=sg(:,:,:,n);
acs=as(:,:,:,n);
af=2
[recon(n), ws(n)]=open(sig, acs, af);
end
however this requires major revision on open.m..
can i somehow put a counter on? say
for n=1:size(sg,4)
sig(1) acs(1) af=2
save recon recon(1)
save ws ws(1)
clear recon
clear ws
% repeat for sig & acs 2,3,4
end
then output will be recon 1, recon 2 ws 1 ws 2 and i can cat them together....
So sorry for rubbish explanation....Thank you so much for your expert help...Cheers.
I do not understand. Do you have a question now?
Perhaps this is less confusing:
save('ws.mat', 'ws');
You cannot save "ws(1)" directly, but you could use a temporary varaible:
data = ws(1);
save('ws.mat', 'data');

Sign in to comment.

Categories

Tags

Asked:

on 23 Mar 2011

Community Treasure Hunt

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

Start Hunting!