how to check the contents of the variables?

조회 수: 2 (최근 30일)
bsd
bsd 2011년 10월 27일
Hai,
While the program is running, how can I check the contents of the variables declared in the program? Looking for your reply.
BSD

채택된 답변

Naz
Naz 2011년 10월 27일
don't put the semi column after the statement
x=5
and you will get the expression in Command Window:
>>x=
>> 5
  댓글 수: 2
bsd
bsd 2011년 10월 27일
Instead of getting it in command window, is it possible to see the variable values in the workspace? Looking for your reply.
BSD
Jan
Jan 2011년 10월 27일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Andreas Goser
Andreas Goser 2011년 10월 27일
When the program is paused, you may be able to see the content in the Workspace Browser.
BUT
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?

Walter Roberson
Walter Roberson 2011년 11월 1일
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.

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by