Making a Script as a Function... How to see variables in workspace?
5 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Geoff Hayes
2014-9-29
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).
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Performance and Memory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!