"pad the filenames with 0's programatically and re-sort. "
I tried this option "Spike Nr_01, Spike Nr_02 ... Spike Nr_010" and the loop is stil taking the spike 11 before de second one.
Rename the files manually is just unacceptable. I have 60 spikes, so six times this error.
Can I change the order of function dir? I've checked the mathlab page and there is nothing about it.