Calling a function from m.file into a pushbutton in GUI
古いコメントを表示
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 件のコメント
Ameer Hamza
2020 年 6 月 5 日
What happens when you run this? What does the function myfun do?
Frederic Rudawski
2020 年 6 月 5 日
Hello,
your code should actually work. Make sure Matlab can find the m.file "myfunction.m" by adding the corresponding folder to Matlab's search path or adding your function file to the GUI execution folder. If it still does not work, try to figure out what Matlab's error message is tellng you.
Good luck!
Maximilian Rauch
2020 年 6 月 5 日
Ruger28
2020 年 6 月 5 日
Probably an obvious question, but is your .m file called myfun.m ?
Maximilian Rauch
2020 年 6 月 5 日
編集済み: Maximilian Rauch
2020 年 6 月 5 日
回答 (1 件)
Ana Gonçalves
2020 年 6 月 5 日
編集済み: Ana Gonçalves
2020 年 6 月 5 日
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);
カテゴリ
ヘルプ センター および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!