Info
This question is closed. Reopen it to edit or answer.
How to make gui alter variables in the base area?
1 view (last 30 days)
Show older comments
Hi, I am in the process of forming a gui to retrieve data from a camera, and enable the user to set certain settings for the camera before running a set of tests. I have asked a question before on this but I am stuck again...
Can someone explain to me how I edit settings in the main matlab base from the gui please? For example, I have created a tab named "program settings", and I want to choose which "acquisition mode" to run when I start the camera. It has a few values from 1,2,3,4,5, etc all linking to a different setting. How can I code so that whatever setting I choose in the list edits the value in the main matlab base making the camera run with this property?
Sorry if this is simple I am new to gui and don't have much experience with matlab.
I have attached some images to try and illustrate what I am talking about
Thanks
2 Comments
Adam
on 19 Aug 2014
Edited: Adam
on 19 Aug 2014
I'm not sure I fully understand what you are trying to do.
In general you shouldn't be trying to change variables in the base workspace from a GUI.
The GUI has its own data associated with it and a workspace of sorts through the handles structure that is attached to the gui and is passed to every callback.
You can attach whatever data you want to this handles structure, always making sure that you call guidata( hObject, handles ) or guidata( gcbo, handles ) at the end of your function to update the GUI's handles structure to that of your currently executing callback.
That means you can set some parameter in the callback of one GUI component and access that parameter from the callback of another GUI component. Or using listeners or direct access via handles to other GUI components you can trigger actions from a GUI component's callback.
For example you could put all those program settings onto the handles structure, e.g.
handles.readMode = get( handles.editBox1, 'String' )
or whatever kind of UI control you have.
Then wherever you trigger off your camera from can access these parameters from the handles structure.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!