how do I open files automatically in certain order?(numbers giving me trouble)
Ältere Kommentare anzeigen
So, say I have these files named 1.0.txt, 1.5.txt, 2.0.txt, 2.5.txt, ... 10.0.txt, 10.5.txt
I am automatically opening the files by loop and do what I have to do with the file.
However, Matlab seems to see the file order starting from the first letter.
There fore, Matlab executes the loop in the order of 1.0.txt, 1.5.txt, 10.0.txt, 10.5.txt, 2.0.txt, 2.5.txt... and so on.
I can I avoid this and make the loop go in the order of 1.0, 1.5, 2.0, 2.5, ... 10.0, 10.5 ?
I am doing fprintf and the order is important for my calculation..
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 27 Jan. 2016
2 Stimmen
You're going to have to get the base filename, and parse it to find the number. Try using sscanf() or str2double().
Kategorien
Mehr zu Programming 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!