How to insert pre-written functions into GUI
3 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Brendan Hamm
on 21 Jul 2015
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 Comments
Jan
on 22 Jul 2015
You do not need to know the location. All you have to know is if the function can be found by Matlab.
Jan
on 22 Jul 2015
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
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!