Order of filenames is wrong
    6 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Hello,
I have save some measures in loop with
SNR = 30
SNR_steps = 15
-SNR:SNR_steps:SNR
ans =   -30   -15     0    15    30
I use SNR also in part of the filename and I get:

The Problem: the order of files in the folder is (-015 before -030), but I want to have -030, -015, 000, 015, 030...
Why is this happening, and how can I avoid this situation? 
Thank you!   
3 Commenti
  Rik
      
      
 il 3 Lug 2020
				Use the function suggested in the answer below to read the filenames in the order that fills your array in the order that makes sense to you.
Risposte (1)
  KSSV
      
      
 il 3 Lug 2020
        Use this fileexchange function:
2 Commenti
  Image Analyst
      
      
 il 3 Lug 2020
				Not sure it will work, but there are lots of options with it to try
  Stephen23
      
      
 il 3 Lug 2020
				
      Modificato: Stephen23
      
      
 il 4 Lug 2020
  
			Note that a suitable regular expression will have to be provided as the second input argument, as by default natsortfiles uses the natsort default of matching digits only (i.e. positive integers including zero). For example:
'[-+]?\d+'
or in case you only need to match that one number:
'[-+]?\d+(?=_PLL)'
You should also return its third output argument to confirm that the required numbers are being correctly converted to numeric.
Vedere anche
Categorie
				Scopri di più su Shifting and Sorting Matrices in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




