Why can't I import multiple files?
Antworten (1)
8 Kommentare
Looking at the filename that is generated would have immediately showed you what was wrong. I gave you a wrong format string. Correct one should be:
file = sprintf('%01d.txt', k);
On the other hand, I also gave you code that is guaranteed to generate the correct filenames whatever their name is since it simply asks the OS for their name. So whether it's '1.txt', '01.txt' or '001.txt' it'll load it.
@George: It would be much easier, if you post the text and code as text, not as screen shot. As I guessed, you forgot the path. dir(FolderName) imports the contents of the folder. You did not catch the output in a variable, such that the work is wasted. Much better:
Folder = 'C:\Users\...tooLazyToTypeThisFromYourScreenShot\'
...
mydata{k} = imread(fullfile(Folder, file));
But Guillaume's approach is much better, because it does not depend on the numbering method. +1
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!