Borrar filtros
Borrar filtros

Determine current stack level

3 visualizaciones (últimos 30 días)
Jim Hokanson
Jim Hokanson el 26 de Mayo de 2012
The goal is to be able to write a function which opens the editor to the current stack level. This is fairly easy to do for the top of the stack but more difficult if the current stack level is changed, such as via the use of dbup and dbdown. Opening the editor to a file at a specific line is fairly easy using, matlab.desktop.editor.openAndGoToLine. The difficult part is determining the level.
The simple solution is to do the following:
[s,I] = dbstack('-completenames');
matlab.desktop.editor.openAndGoToLine(s(I).file,s(I).line)
I don't like that this creates variables in the workspace and that it is so long. Ideally, I want to have a simple command like this:
open2ws
Some problems:
  • called functions get added to the top of the stack, not to the current workspace, so calling a function erases any information of where you were in dbstack
  • mfilename doesn't work on the current stack level, but on the top of the stack
The best solution I have is: eval(open2ws), where open2ws passes a string with the function whos in it, and the nesting information in whos can be used to identify the current function (I think). Any cleaner suggestions?

Respuestas (0)

Categorías

Más información sobre Debugging and Analysis en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by