필터 지우기
필터 지우기

Is it possible to use exist function in a loop?

조회 수: 1 (최근 30일)
Abhijeet
Abhijeet 2012년 12월 5일
for i=1:5
filename_1 = ['E:\Abhi\file_',num2str(i)];
save (filename_1)
end
for j=1:9
filename_1 = ['E:\Abhi\file_',num2str(j)];
exist('filename_1','file') % not sure how to write this exactly
end
here I expect to get answer 2 for file_1 to file_5 and for rest others as 0.
Thanks.

채택된 답변

Matt Fig
Matt Fig 2012년 12월 5일
Did you try it? The help for EXIST indicates you can use it as you are doing.
  댓글 수: 3
Matt Fig
Matt Fig 2012년 12월 5일
exist([filename_1,'.mat'],'file')
Abhijeet
Abhijeet 2012년 12월 5일
Thank you very much!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by