Access handles structure in a GUI

1 view (last 30 days)
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?

Accepted Answer

Image Analyst
Image Analyst on 8 Jan 2014
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 Comments
Image Analyst
Image Analyst on 8 Jan 2014
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.
Christine
Christine on 10 Jan 2014
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!

Sign in to comment.

More Answers (0)

Categories

Find more on Debugging and Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!