Author Topic: Looping problem :(  (Read 605 times)

Offline Rai

  • Newbie
  • *
  • Posts: 1
  • Matlab Forum
    • View Profile
Looping problem :(
« on: January 28, 2011, 10:28:40 AM »
Hi
 
i need some help with matlab. I have multiple csv files which I would like to process them in a loop. I have 12 files (16Nov_1, 16Nov_2,....16Nov_12). I need to load all the files and peform an operation on each file using the plotting.m file. Also i need to save all the figures plotted. However the loop doesnt seem to work. I only manage to plot the first file(16Nov_1). Appreciate if anybody could help me with this. Thank you :) 
 
code:
files=dir('*.csv');
for k=1:length(files);
first=csvread(files(k).name);
plotting.m;
end
 
plotting.m code:t=first(:,1);
v=first(:,2);
plot(t,v,
'-'); xlabel('time(s)'); ylabel('voltage(V)');
saveas(gcf,
'%d.fig')

Matlab and SimuLink Development Forum

Looping problem :(
« on: January 28, 2011, 10:28:40 AM »