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

2 ビュー (過去 30 日間)
Cole
Cole 2014 年 9 月 29 日
コメント済み: Cole 2014 年 9 月 29 日
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

採用された回答

Geoff Hayes
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).
  1 件のコメント
Cole
Cole 2014 年 9 月 29 日
Geoff,
Thanks! Exactly the easy fix that I was looking for!
Cole

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by