MATLAB Answers


how to check the contents of the variables?

Asked by bsd
on 27 Oct 2011
Accepted Answer by Naz


While the program is running, how can I check the contents of the variables declared in the program? Looking for your reply.





No products are associated with this question.

3 Answers

Answer by Naz
on 27 Oct 2011
 Accepted answer

don't put the semi column after the statement


and you will get the expression in Command Window:

>>  5


on 27 Oct 2011

Instead of getting it in command window, is it possible to see the variable values in the workspace? Looking for your reply.


Jan Simon
on 27 Oct 2011

Does "see values in the workspace" mean in the workspace browser? Does this make sense, when the program is running and the value is changing frequently? Setting a debugger breakpoint seems to be a good idea.

Answer by Andreas Goser
on 27 Oct 2011

When the program is paused, you may be able to see the content in the Workspace Browser.


It again depends on your application. You are asking multiple simple sounding questions, but they need a context to give you a good solution.

Maybe, it is the most efficient and effective way for everybody to make a call together with your supervisor and Technical Support?


Answer by Walter Roberson
on 1 Nov 2011

If your program is actively running and not paused for keyboard input (or the debugger), there is no way to examine variables in any of the workspaces. The command window will not execute commands while the program is running, and there is no mechanism in MATLAB to pause execution "where-ever the program happens to be now".

The closest you can get to this is to create a graphic button whose callback sets a variable that your code examines, with the code calling keyboard() or setting a breakpoint to give the user a chance to poke around.


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!