How to open file array with fopen?
16 次查看(过去 30 天)
显示 更早的评论
Hi, I have a list of files that look like this:
J={'File1', 'File2', 'File3'}
It is not possible to open the file using fopen this way:
for i=1:length(J)
fid=fopen('J(1)', 'r')
%Some algorithms here...
fclose(fid)
end
Is there any possible way to use fopen by using looping? It seems like it only accepts the actual file name. Please help. Thanks!
0 个评论
采纳的回答
Jonathan Sullivan
2013-7-1
You just need to index into J properly. J looks to be a cell array so you need to use curly brackets.
Try replacing your fopen line with this
fid = fopen(J{i},'r');
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!