I really need some concrete examples, because all those "ressources" out there doesn't explain it for me.
GUIDE, calling functions
2 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
Walter Roberson
2011-5-26
2 个评论
Walter Roberson
2011-5-26
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.
更多回答(8 个)
Ivan van der Kroon
2011-5-26
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
2011-5-26
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
2011-5-26
2 个评论
Ivan van der Kroon
2011-5-26
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
2011-5-26
3 个评论
Walter Roberson
2011-5-26
They are in the properties of the figure.
You either deleted something or renamed something.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!