MATLAB Answers

How does one identify the current line being evaluated during execution?

60 views (last 30 days)
Tolulope
Tolulope on 15 Jan 2013
I would like to know if there is a command in MatLab that returns the value of the line number on which it has been executed.
For example:
1
2 for i = 1:10
3 % some line of code
4 currentLine = ?;
5 end
6
7
8
9
Where "?" is some MatLab command or function (if it exists) that identifies the line on which "?" is called, in this case line number 4.

Answers (3)

Wayne King
Wayne King on 15 Jan 2013
Look at the help for dbstop
For example:
dbstop in FILESPEC at SUBFUN

  0 Comments

Sign in to comment.


Image Analyst
Image Analyst on 15 Jan 2013
I don't know why you need the number. You can issue the "echo on" command and it will spit out the current line being executed to the command window, without a line number though. When you have functions and other m-files, the concept of line number becomes not so clear.

  0 Comments

Sign in to comment.