How to read several files
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
Hello
I have several mat files which are named as following.
Inv_A_1.raw.mat , Inv_A_2.raw.mat , Inv_A_3.raw.mat
Inv_B_1.raw.mat , Inv_B_2.raw.mat , Inv_B_3.raw.mat
Inv_C_1.raw.mat , Inv_C_2.raw.mat 
Inv_D_1.raw.mat , Inv_D_2.raw.mat , Inv_D_3.raw.mat
I want to use a for loop then I can load each file in each step of the loop.
Thanks in advance for your help
Respuestas (1)
  KSSV
      
      
 el 26 de Jul. de 2022
        
      Editada: KSSV
      
      
 el 26 de Jul. de 2022
  
      files_mat = dir('*.mat');  % your pwd is where mat files are present if not give path 
N_file=length(files_mat);  % total number of files 
% loop for each file 
for ind= 1:N_file   
    thisFile = files_mat(i).name ; 
    load(thisFile);
    % Do what you want 
end
2 comentarios
Ver también
Categorías
				Más información sobre Loops and Conditional Statements 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!

