how to import a lot of data files
    7 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    aliaa madbouly
 el 14 de Sept. de 2014
  
    
    
    
    
    Comentada: Geoff Hayes
      
      
 el 15 de Sept. de 2014
            hello i want to import to matlab a lot of data files with one line to write on MatLab instead of that all line.
- load aae20100101dmin.min
 - load aae20100102dmin.min
 - load aae20100103dmin.min
 - load aae20100104dmin.min
 - load aae20100105dmin.min
 - load aae20100106dmin.min
 - load aae20100107dmin.min
 - load aae20100108dmin.min
 - load aae20100109dmin.min
 - load aae20100110dmin.min
 - load aae20100111dmin.min
 - load aae20100112dmin.min
 - load aae20100113dmin.min
 - load aae20100114dmin.min
 - load aae20100115dmin.min
 - load aae20100116dmin.min
 - load aae20100117dmin.min
 - load aae20100118dmin.min
 - load aae20100119dmin.min
 - load aae20100120dmin.min
 - load aae20100121dmin.min
 
0 comentarios
Respuesta aceptada
  Geoff Hayes
      
      
 el 15 de Sept. de 2014
        Aliaa - try the following
 for k=1:21
     filename = sprintf('aae201001%02ddmin.min',k);
     load(filename);
 end
The above code builds the filename on each iteration of the loop, and then loads the file.
2 comentarios
  Geoff Hayes
      
      
 el 15 de Sept. de 2014
				 sprintf('aae201001%02ddmin.min',k);
The %02d% indicates that the integer that will be inserted into the string should be padded with up to two zeros.
As for what you wish, creating separate local variables for each file read in, I don't recommend that. Instead, I think that you should just store all of this data into a matrix or cell array (if the fourth column of each loaded matrix has a different number of elements)
 % store the data in a cell array
 numFiles = 31;
 data     = cell(numFiles,1);
 for k=1:numFiles
     filename = sprintf('aae201001%02ddmin.min',k);
     S        = load(filename);
     data{k}  = S(:,4);
 end
Más respuestas (0)
Ver también
Categorías
				Más información sobre Workspace Variables and MAT Files en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!