Loop Files from a Directory
Mostra commenti meno recenti
Hi, I want to loop files in a folder. I used the following method:
datadirs = dir('../Inputdata/URL2');
dircell = struct2cell(datadirs)' ;
filenames = dircell(:,1);
datafilename =strcat('../Inputdata/URL2/',filenames(3)); %just a try.
fid = fopen(datafilename);
It gives me an error message.
But when I used:
ff = '../Inputdata/URL2/2017032312_8952.txt'; %(The same as the "datafiename").
fid = fopen(ff);
It worked.
WHY!!!
How to fix the problem?
3 Commenti
KSSV
il 4 Set 2017
What files you want to open in a folder? Do they have any extension?
@Qingsheng Bai: instead of making up your own complicated and buggy syntax, you would be much better off simply copying the examples shown in the MATLAB documentation:
or from here:
KL
il 4 Set 2017
Valid point Stephen. Edited my answer.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su File Operations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!