Extracting multiple data files using a loop for each filename

1 次查看(过去 30 天)
Hi, I am trying to extract data using the abfload function. I have multiple sets of data say: A1.abf, B2.abf, C3.abf etc and I want to extract them, plot and save these plots. I can easily just do:
if true
abfload(A1.abf)
fnam=[fstring, 'szfcsa.eps'];
figure;
plot(A1);
saveas(gcf,['C:blahblah,filesep,fnam],'eps');
end
(where I define the strings earlier) Is there someway of doing all of this in a loop? When i try:
if true
for i = {'A1.abf','B2.abf','C3.abf'}
abfload(i);
figure;
plot(i);
end
end
I get errors, I am also unsure how i would go about saving these plots

回答(1 个)

Image Analyst
Image Analyst 2014-10-7
This question is asked a lot , probably more than any other question. See the FAQ for code samples: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
  1 个评论
Image Analyst
Image Analyst 2014-10-7
Did you see the second code example there? You can use dir() to put in any file pattern you want, for example dir('*.abf'). You can sort what you get back if you want, or take it just as the operating system gives it to you.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by