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

조회 수: 5 (최근 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 CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by