How to insert pre-written functions into GUI
4 ビュー (過去 30 日間)
古いコメントを表示
I found the online tutorial on how to make a simple GUI for Matlab (programmatically, not with GUJIDE). Once I have a GUI written in this format, how can I insert functions I have already made into this function to be accessed by push buttons? For instance, I have a function that plots the exceedance curve of the data and I want the user to be able to display this plot/data by pressing a button labeled "exceedance curve". I have version R2015a if that helps.
0 件のコメント
回答 (2 件)
Brendan Hamm
2015 年 7 月 21 日
All that matters is that your pre-written function is on the MATLAB search path (and that it is the first one found). So for instance if I want to use the pre-written function myFunc. I can check if it is accesible by typing:
which myFunc
If the result is the location of the file on my computer, then I am all set to use this. Otherwise, add it using the instructions in the above link (It is good practice to add your function to the end of the search path).
2 件のコメント
Jan
2015 年 7 月 22 日
You do not need to know the location. All you have to know is if the function can be found by Matlab.
Jan
2015 年 7 月 22 日
Your functions are treated exactly as all other Matlab commands. The code need not be copied into the file, which creates the GUI. Example:
function myGUI
FigH = figure;
ButtonH = uicontrol('String', 'Button', 'Callback', @myCallback);
function myCallback(ObjectH, EventData)
disp(sin(0.2)); % Call arbitrary Matlab functions
startMyIntegration(1,2,3); % Call your code
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!