How to insert pre-written functions into GUI
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Brendan Hamm
el 21 de Jul. de 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 comentarios
Jan
el 22 de Jul. de 2015
You do not need to know the location. All you have to know is if the function can be found by Matlab.
Jan
el 22 de Jul. de 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
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!