Search code examples
matlabfunctionworkspace

Look through the function workspace in Matlab


Let's imagine that you are dividing your script by parts using functions. Every one has its own workspace. Is there any way to switch between workspaces and directly have a look at its content? It's just like we do with the base workspace.


Solution

  • If you only want to inspect different (read: parent) workspaces, you can do that while debugging using the "Function Call Stack" menu as shown below:

    Callstack selection during debug

    Each of the displayed lines (in this example: updateSourceImageAndStats, loadCallback, Base) represents a different workspace, and switching between them will show you the contents of the workspace for that level. Also consider dbstack and related functions.

    If however you want to execute code in some parent workspace, you can use evalin.