Extracting multiple data files using a loop for each filename

조회 수: 1 (최근 30일)
Bill
Bill 2014년 10월 7일
댓글: Image Analyst 2014년 10월 7일
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