Is it possible to use exist function in a loop?

1 次查看(过去 30 天)
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.

更多回答(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