I would like to add an optional function command at the end of a script that logs the command window to a file.
I know that diary gets the job done, but diary must be activated at the beginning of the execution, and this is not always possible.
I also know that the diary command can be put in the startup.m file so that it is automatically started with the Matlab session, but also this option is not always a feasible solution (I don't have control of the computer where the code is run).
There can be also many other objections for my intention to not using diary, but let's assume that I am at least curious: is it possible to mimic the "select all"+"copy" sequence to get all the text that is available in the command window at a specific moment? the output can be stored in a variable or file, it is not important.
Thank you for your help