I have inherited multiple scripts in Matlab and sometimes it's tricky to trace where the execution is happening. I would like to create a log file to show where it is in the execution, show warnings and show errors and date and time stamps. [Note: I'm using Matlab R2012a].
Asked
Active
Viewed 4,131 times
2
-
Have you tried this: http://www.mathworks.com/help/rptgen/ug/creating-log-files.html ? – Dan Jan 03 '14 at 10:26
-
I'm using Matlab R2012a, I don't think this option is available. I was also checking matlab -logfile 'logfile.txt' but not working either. – cloudviz Jan 03 '14 at 10:30
-
Hmmm... it may have come in R2012b. According to [this](http://www.mathworks.com/help/matlab/matlab_env/startup-options.html) `matlab -logfile 'logfile.txt'` should have worked. How to you go about it? – Dan Jan 03 '14 at 10:42
-
I did a quick test in the command prompt: matlab -logfile 'logfile.txt' then i get the error matlab -Undefined function 'matlab' for input arguments of type 'char'. – cloudviz Jan 03 '14 at 10:55
-
1Were you in the right folder? Otherwise maybe try using a startup file: http://www.mathworks.com/help/matlab/matlab_env/startup-options.html#brlkmbe-1 – Dan Jan 03 '14 at 12:00
-
It works if I do it in the Windows CMD. I had to CD into the directory of were the Matlab.exe is then start ML using this Matlab.exe -logfile 'matlog.txt'. – cloudviz Jan 05 '14 at 10:18
-
I guess that's the answer then. So you can use a startup file to make it happen every time. Otherwise if you right click on the Matlab icon in Windows, you should see some sort of startup properties options? Somewhere to give it added command line arguments. Give that a try. – Dan Jan 06 '14 at 06:19
-
2I don't think this should have been closed, the OP has mentioned a very valid attempt in the comments. Also this is directly related to a programming tool. – Dan Jan 06 '14 at 06:20
-
1I agree with Dan. This question shouldn't be closed. T had the same problem and found a very good tool [log4m](http://www.mathworks.com/matlabcentral/fileexchange/37701-log4m-a-powerful-and-simple-logger-for-matlab) doing exactly the logging functionality. – Semjon Mössinger Jan 14 '15 at 10:02