How to fopen in this case?
    1 Ansicht (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    dmfwlansejr
 am 21 Feb. 2023
  
    
    
    
    
    Kommentiert: dmfwlansejr
 am 21 Feb. 2023
            Hi Everybody
Case1
 fid = fopen('TTL_1.txt', 'w');
 fprintf(fid3,'%s \n','ABCD;');
 fclose(fid3);
Case2
 file_name='TTL_1';
 fid = fopen('file_name.txt', 'w');
 fprintf(fid3,'%s \n','ABCD;');
 fclose(fid3);
Case1 is OK!
However, Case 2 does not create a file.
How to fopen in this case?
Thanks!
0 Kommentare
Akzeptierte Antwort
  the cyclist
      
      
 am 21 Feb. 2023
        You need to concatenate two character arrays, one of which you defined ahead ...
file_name='TTL_1';
fid = fopen([file_name,'.txt'], 'w');
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Unit Conversions finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

