Issue with length function
29 views (last 30 days)
Show older comments
julian gaviria on 14 Mar 2022
Commented: Rik on 14 Mar 2022
Why does the length function never stops the iteration?
Context: Using copyfile function (matlab2018b) for copying and pasting indexed files. To note, the files are rightly copied and pasted. But the iteration never ends. Even if Idelet the files in the destination folder, it keeps pasting them.
Participant = 'Session_2\scans\87627';
SourceFolder = fullfile([SourcePath,Participant],'RUN_1_MIST_1_0004');
DistFolder = fullfile(DistPath,'FunRaw_S1');
Geoff Hayes on 14 Mar 2022
@julian gaviria - why aren't you using the i in your loop?
So it would seem that the above code would try to copy the full set of files for every file in the directory that matches the condition. Perhaps the following might help
filesToCopy = dir(fullfile(SourceFolder,'f*'));
Rik on 14 Mar 2022
You may not see a misuse, but I'm of the opinion you should see a bad habit. Did you intend the number of elements? Then you can more reliably get that with numel. Did you really want max(size(X))? I have never seen anyone who actually wanted that.
More Answers (0)
Find more on Introduction to Installation and Licensing 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!