I really need some concrete examples, because all those "ressources" out there doesn't explain it for me.
GUIDE, calling functions
2 views (last 30 days)
Show older comments
Hi all, might just be me, but I am having a hard time finding som info on GUIDE that I can use, I know nothing of GUIDE, but I know how to use and do code in matlab, but my problem is how to make a GUIDE that executes a function which lies in a seperate m-file when pushing a pushbutton
and also how to run a function with parameters, when i have two textboxes and a button, still running a function in a seperate m-file.
Is this even possible? searched google and mathworks without getting a usable answer.
Accepted Answer
Walter Roberson
on 26 May 2011
2 Comments
Walter Roberson
on 26 May 2011
Set the CallBack property of the button to
{@(src, event, handles) YourFunctionName(Parameter1, Parameter2, ....)}
I am not completely sure if handles will be passed by default.
More Answers (8)
Ivan van der Kroon
on 26 May 2011
A gui is just some visualization of some m-file. If you want to call a separate m-file you have to call it in the first one.
If you want to call this functions with parameters you have to set them in the m-file as well, probably by adding some slider in your gui and then call the m-file with these variables as input.
Remember that a gui is just an interface and the execution is in the m-file.
Ivan van der Kroon
on 26 May 2011
When you are using the guide it is actually a gui for making gui's. What you are actually doing is making an m-file and this m-file makes a figure with some buttons, bullets and values. These are the callbacks and they are nothing else than changing values in the m-file's workspace.
For instance type
xpsound
and you see Matlab's sound capability gui. If you would instead type
edit xpsound
you get to see the m-file which generates this figure and its callbacks. In this case the volume bar is an example of a slider.
It appears that you only know how to make gui's with guide. Is that correct? I never made one with guide, but there should be a way to call other functions. If you cannot find it, I would suggest to add some arbitrary callback, save your gui and then change it in the m-file to execute another m-file of your choosing.
Johan
on 26 May 2011
2 Comments
Ivan van der Kroon
on 26 May 2011
I'm sorry, but I'm not familiar with vba. There are a lot of tutorials in matlab to learn how to make gui's.
So, did you look into xpsound? The simplest action is the info-button. On line 330 it is checked for clicks and on line 331 it executes a simple command if it is clicked. Now just change this command with the m-file you want to call. You also mentioned assigning variables to the functions and lines 316-327 are examples of that.
Johan
on 26 May 2011
3 Comments
Walter Roberson
on 26 May 2011
They are in the properties of the figure.
You either deleted something or renamed something.
Johan
on 27 May 2011
1 Comment
Ivan van der Kroon
on 30 May 2011
Well, your doing handles when using figure! Nice to get it working!
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!