To Run a program for multiple times for different data and report result for each run
    1 次查看(过去 30 天)
  
       显示 更早的评论
    
I have a program as follows:
A=textread('VMIVolt.asc');
t=0:1:1000;
h=hist(A(:,1)./1000,t);
meanBinIndex = sum(t(620:720) .* h(620:720)) / sum(h(620:720))
BckgndCrctd_h=h-meanBinIndex;
plot(t,h,'*b',t,BckgndCrctd_h,'*r')
How can I make this program run for different files namely "VMIVolt1.asc","VMIVolt2.asc","VMIVolt3.asc" etc. and give plots for each file (as subplots or separate plots, doesn't matter)?
0 个评论
采纳的回答
  Andrei Bobrov
      
      
 2013-11-26
        
      编辑:Andrei Bobrov
      
      
 2013-11-26
  
      n = 10; % let number of your .asc files
outdata = cell(n,2);
t=0:1:1000;
figure;
for jj = 1:n
    nme = sprintf('VMIVolt%d.asc',jj);
    A = textread(nme);
    h=hist(A(:,1)./1000,t);
    meanBinIndex = sum(t(620:720) .* h(620:720)) / sum(h(620:720));
    BckgndCrctd_h=h-meanBinIndex;
    subplot(n,1,jj);
    plot(t,h,'*b',t,BckgndCrctd_h,'*r');
    outdata(jj,:) = {h,BckgndCrctd_h};
end
更多回答(0 个)
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

