I'd like to skip the file that's not there and bring it up!
1 view (last 30 days)
Show older comments
KRLKL on 17 Mar 2023
Hello, I am a student who is learning mat rap. I left a question because I didn't know something while doing the assignment.
The codes I have to sing are NO_001, NO_002,...Code up to NO_100.
There is a missing number among the 100 numbers.
I want to keep the for statement except for this missing file, but I don't know what function to put in it.
if isempty( )
Stephen23 on 19 Mar 2023
Edited: Stephen23 on 20 Mar 2023
A simple alternative approach is to use DIR, then you can simply avoid the problem:
S = dir('01__input/NO_*.mat');:
for k = 1:numel(S)
F = fullfile(S(k).folder,S(k).name);
D = load(F,'data');
.. do whatever with D.data, or store for later processing:
S(k).data = D.data;
John D'Errico on 17 Mar 2023
Edited: John D'Errico on 17 Mar 2023
mat rap? Is that some godawful new song I've never heard before? ;-) That just seems, well, raprehensible to me.
You don't want to use isempty there. Instead, use the exist function. Test to see if the file exists, BEFORE you try to load the file. If it does not exist, then do you want to try load it in the first place?
John D'Errico on 19 Mar 2023
Why is it every older generation never seems to undertand the music of today, regardless of what generation we are in? Let me ask MATLAB...
Gosh, I'm not sure that explains anything. Darn computers.
Anyway, I had to laugh a little. But MATLAB does not understand rap either. For example,
It does try. But it gets confused. :)
Anyway, have a nice day. I'm happy to have made you smile.
More Answers (0)
Find more on Install Products in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!