Making a Script as a Function... How to see variables in workspace?

1 Ansicht (letzte 30 Tage)
Cole
Cole am 29 Sep. 2014
Kommentiert: Cole am 29 Sep. 2014
Hi,
This has probably been asked before but I can't find the answer. Up until now, I've always just wrote my code in Matlab as a script. Doing this, it's easy to check arrays in the workspace. I'm now doing much more complicated things with Matlab so I'm trying to write "better" code, use more functions etc.
I've started writing using the syntax below. The problem with this is that I can no longer see my variables in the workspace. Is there an easy way to see the variables? I like to look at certain variables to make sure they are doing what I want done, the correct values etc. I also like to type the variables into the command window to look at how the array filled sometimes.
I know that I can add a specific variable to the function output and look at it that way but it's a pain. There has to be a better way!
Thanks,
Cole
% Main code: function My_Script()
stuff here
out = sub_rountine_one(in)
more stuff here
return
% Subroutines:
function [out] = Sub_Routine_One(in) stuff here return
function [out] = Sub_Routine_Two(in) stuff here return

Akzeptierte Antwort

Geoff Hayes
Geoff Hayes am 29 Sep. 2014
Cole - you can put a breakpoint on the last line of code within your function. Then, execute the function (from the Command Window), and when the debugger pauses on that final line, all local variables that were created within that function will be visible in the Workspace window (as before).

Weitere Antworten (0)

Kategorien

Mehr zu Debugging and Analysis finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by