how to define a variable in directory to save many of .mat in loop?
    1 visualizzazione (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Osama Tabbakh
 il 8 Mar 2019
  
    
    
    
    
    Commentato: Osama Tabbakh
 il 9 Mar 2019
            Hallo, i am trying the whole time to create a folder and in this folder must be a lot of folders, where I would to save my .mat.
as = 2;
for i =1:as
    mkdir(['H_L']);
    g = fullfile ('H_L',num2str(i));
     mkdir(g)
    save('D:\Input_data\H_L\',num2str(i),'\Leiter','Name_Variable_Workspace')
end 
please don't send me a link for another question, because I've seen all questions but i can't do it anyway. thanks in regard
0 Commenti
Risposta accettata
  ADragon
      
 il 8 Mar 2019
        Hi Osama, not 100% clear on what you are trying to do, but you definitely have a problem with the save line.  If you are trying to create a filename string you will want to enclose the concatenated strings in brackets, such as:
save(['D:\Input_data\H_L\',num2str(i),'\Leiter'],'Name_Variable_Workspace')
Otherwise the save function will try to interpret the command as multiple input arguments.  I don't think you want this.  Also I would take mkdir(['H_L']); outside the for loop as it only needs to be created once.
ADragon
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Loops and Conditional Statements 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!

