Filter löschen
Filter löschen

Calling a function from m.file into a pushbutton in GUI

1 Ansicht (letzte 30 Tage)
Maximilian Rauch
Maximilian Rauch am 5 Jun. 2020
Bearbeitet: Ana Gonçalves am 5 Jun. 2020
Hi,
I have a m.File with the a function "myfun(input)" and a GUI with a pushbutton. I want to run that mfile function by pressing the pushbutton. I don´t know how to implemente it correctly into the pushbutton-function.
Any help would be great!
This one doesn´t work :/:
function generatebtn_Callback(hObject, eventdata, handles)
input=xyz;
myfun(input);
Thank you:)
  5 Kommentare
Ruger28
Ruger28 am 5 Jun. 2020
Probably an obvious question, but is your .m file called myfun.m ?
Maximilian Rauch
Maximilian Rauch am 5 Jun. 2020
Bearbeitet: Maximilian Rauch am 5 Jun. 2020
I´m new to Matlab ...I thought with myfun I would only call the m.File to run and not the function itself(with its inputs).
Thank you and sorry for the stupid question :D

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Ana Gonçalves
Ana Gonçalves am 5 Jun. 2020
Bearbeitet: Ana Gonçalves am 5 Jun. 2020
To open .m files with a pushbutton use this:
% --- Executes on button press in pushbutton
function pushbutton_Callback(hObject, eventdata, handles)
strM_File = ('C:\Users\Desktop\Matlab\YourMFileNameHere.m'); %The folder which contains your .m file
open (strM_File);

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by