Function in for loop

조회 수: 9 (최근 30일)
Tamas Brigancz
Tamas Brigancz 2016년 2월 11일
댓글: Tamas Brigancz 2016년 2월 11일
Hi I need to read data from .wfm files. Each file has 25 frames from the oscilloscope and I need the y and t data. The filenames are tdpo001_ch1.wfm ... tdpo150_ch1.wfm and I have no idea how to make the middle of the filename as the variable for a for loop. Thanks for the answer in advance!

채택된 답변

Guillaume
Guillaume 2016년 2월 11일
편집: Guillaume 2016년 2월 11일
Use sprintf:
for fileidx = 1:150
filename = sprintf('tdpo%03d_ch1.wfm', fileidx)
%... use filename
end
The '%03d' in format string means replace with the string representation of fileidx as integer, padding with zero to a size of 3 characters.
  댓글 수: 1
Tamas Brigancz
Tamas Brigancz 2016년 2월 11일
I got it now, thank you!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by