필터 지우기
필터 지우기

How rename files with loop

조회 수: 24 (최근 30일)
Maxime
Maxime 2014년 5월 5일
편집: Matt J 2014년 5월 5일
Hello I constructed a loop with witch I created one file per iteration :
example :
subject = {'1' '2' '3'....etc};
for i = subject
with_my_procedure_I_created_myfile = A
end
I would like in each iteration that myfile "A" can be rename by :
A1 for the first iteration
A2 for the second
A3 for the third ... etc
How can I do ???

답변 (2개)

Matt J
Matt J 2014년 5월 5일
편집: Matt J 2014년 5월 5일
One way, e.g.,
>> names=arrayfun(@(i)['A' num2str(i)],1:5,'un',0)
names =
'A1' 'A2' 'A3' 'A4' 'A5'
and then of course
for i=1:length(names)
thisname=names{i};
end

Image Analyst
Image Analyst 2014년 5월 5일
Use sprintf() like the first code block in the FAQ shows you: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
In the loop, create your input and output filenames, then use movefile() to do the renaming .

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by