Cycling through file names in a struct
Mostra commenti meno recenti
I have an nx1 struct which contains the names of all the files in the directory Im using. For context, here's an example 6x1 struct:
'677_FM02_HF_6-16-2020.ep' 'C:\Users\Desktop\F-DAS Matlab\ProcessFiles' '04-Jan-2021 13:49:41' 10644 false 738160.576168982
'685_FM01_HF_7-21-2020.ep' 'C:\Users\Desktop\F-DAS Matlab\ProcessFiles' '04-Jan-2021 13:49:41' 10619 false 738160.576168982
'689_FM03_HF_6-16-2020.ep' 'C:\Users\Desktop\F-DAS Matlab\ProcessFiles' '04-Jan-2021 13:49:41' 10644 false 738160.576168982
'699_FM04_HF_.6-16-2020.ep' 'C:\Users\Desktop\F-DAS Matlab\ProcessFiles' '04-Jan-2021 13:49:41' 10642 false 738160.576168982
'766_FM06_HF_6-15-2020.ep' 'C:\Users\Desktop\F-DAS Matlab\ProcessFiles' '04-Jan-2021 13:49:41' 10625 false 738160.576168982
'786_FM05_HF_6-15-2020.ep' 'C:\Users\Desktop\F-DAS Matlab\ProcessFiles' '04-Jan-2021 13:49:41' 10919 false 738160.576168982
I want to cycle through the first column (the name column) in a for loop where each loop saves the file name as a variable.
So far the code I have is
FMdir = dir('*FM*.ep'); %Get a list of all of the final measurement files in the directory
FMn = numel(FMdir);
for n= 1:FMn %cycle through
if( isnumeric(FMdir.(fn{n})))
end
But it's throwing an error saying
Error using isnumeric
Too many input arguments.
Error in ProcessFilesTry (line 19)
if( isnumeric(FMdir.(fn{n})))
end
Anyone know how I can fix this?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Loops and Conditional Statements 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!