How to check in which step MATALB code is running?

53 views (last 30 days)
Ketan on 25 Aug 2014
Answered: Ben11 on 25 Aug 2014
I have made a code which took approx 4-5 hours to execute.....So how could I know on which step that code is running and how much time will it take to complete ?

Answers (2)

Star Strider
Star Strider on 25 Aug 2014
Without seeing the code it’s impossible to say exactly. However when I run long simulations (usually with at least one loop), I start a time counter with the clock function at the beginning of the program (before the start of the loop), and just prior to the ends of the main loop, I put an fprintf statement that reports what the loop counter is, uses the etime function to show how long that loop took, and another calculation of how long the entire program has been running. All that prints in the Command Window. One fprintf statement like that doesn’t slow the code down noticeably, but it can be reassuring.

Ben11 on 25 Aug 2014
You might also want to look into dbstack, which tells you the actual line of code being executed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by