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.
Johan
2011 年 5 月 27 日
1 件のコメント
Ivan van der Kroon
2011 年 5 月 30 日
Well, your doing handles when using figure! Nice to get it working!
参考
カテゴリ
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!