Overwriting a diary file
    27 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Karanvir singh Sohal
 le 12 Mai 2019
  
    
    
    
    
    Commenté : Jimmy Neutron
 le 29 Oct 2020
            I want to save my output to .txt file. I have used 
diary Output.txt
diary on
    some code
diary off
It saves diary file in same directory. But when I run the same code again it writes the command window output under the previously saved content instead of overwriting. I want to overwrite the previous content and make a file having only single output.
0 commentaires
Réponse acceptée
  Walter Roberson
      
      
 le 12 Mai 2019
        dfile ='Output.txt';
if exist(dfile, 'file') ; delete(dfile); end
diary(dfile)
diary on
5 commentaires
  Walter Roberson
      
      
 le 26 Juin 2019
				It would probably be a good idea to fully qualify the diary file name, in case you are not in the same active directory that you think you are.
  Jimmy Neutron
 le 29 Oct 2020
				@Andrew Robison If you add 
diary off
at the end of your .m file, everything works fine
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur File Operations dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



