I am programming a GUI and am storing a lot of variables in the handles structure. Sometimes I just want to have a look on one of these variables. So I would like to create a button that just gets the handles structure, lets me to look at it in the workspace, make changes if I want, and then returns to the usual program.
Any idea how I could do that?

 채택된 답변

Image Analyst
Image Analyst 2014년 1월 8일

0 개 추천

If you stop at a breakpoint you can edit things in the variable editor - just double click on the handles name you see in the workspace. Or you can do it in the command window:
>> handles.yourVariable = someNewValue;
If you want to display all the fields in a listbox or somewhere then you can use the fieldnames function.

댓글 수: 3

Christine
Christine 2014년 1월 8일
But how can I build a function that sets the break point for me?
dbstop may do it. But maybe you want to display the fields in a listbox and ask your user which one she wants to edit. Then you accept the new value and you do it in the callback code:
% 1) Ask what field
% 2) Ask what new value they want
% 3) Assign new value to the field
handles.whatever = someNewValue;
return;
If your users don't have access to the MATLAB development environment with the ability to set break points, I don't know that you want them to just randomly go changing your handles variables whenever they want. Doesn't sound like good programming practice to me. There are better ways of having the user change setting, like controls such as scroll bars, checkboxes, edit boxes, etc.
Ha, now I found it. The line
keyboard
does the job.
I agree that this might be not the best programming practice. Mainly I use this by myself for looking at variables (usually pretty huge matrices) that the program does not display explicitly if the program gives me some strange output. Probably I will need it mainly during debugging and maybe delete this possibility later on.
Thanks for your help!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기

질문:

2014년 1월 8일

댓글:

2014년 1월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by