How to save contents of MATLAB's command windows to in a file? -


i want save in "command window" file automatically. there way it?

you have few options available saving content command window:

  • you can using diary command. automate records modifying startup.m file turn on text logging:

    diary('mytextlog.txt');  %# text appended if file exists 

    and modify finish.m file turn logging off:

    diary('off'); 

    this automatically store entire text content of command window every matlab session, grow rather large text file.

  • another option besides using diary command , modifying startup.m , finish.m files start matlab using -logfile option:

    matlab -logfile "mytextlog.txt" 

    although i'm not sure if overwrite text file or append each time start matlab.

  • if you're wanting save output evaluating 1 or more expressions, can use evalc function evaluate string containing expression , capture output go command window in character array. can print character array file using fprintf.

  • finally, if you're not interested in saving displayed output commands type, instead want store commands themselves, command history want. matlab automatically stores history.m file maximum size of 200,000 bytes, deleting oldest entries when newer ones added.


Comments