필터 지우기
필터 지우기

Running Scripts in the GUI

조회 수: 6 (최근 30일)
mohamed
mohamed 2012년 12월 14일
Hello everyone,
i have made a .m file and im new to matlab, i want to use this .m in the GUI. This is i want to make: GUI with a pushbuttom1 and text beside it so if you write a text file name in there it will get you a function i have made already, after that i want all the data that i get in the matlab appear in a Listbox.
i made the design its easy but how to hyberlink that codes with the design i cant do it at all :(
i wish if there anyone could help thank you

채택된 답변

Evan
Evan 2012년 12월 14일
편집: Evan 2012년 12월 14일
Did you design your GUI using guide? That will make things much easier, especially if you're new to Matlab as you mention.
If the GUI is made in guide, an mfile will be generated once you save the GUI. After that, you would just need to put your code in the pushbutton's callback. I wouldn't think it would take a ton of code to do what you want, just something like this:
function pushbutton1_Callback(hObject, eventdata, handles) %button callback
func_name = get(handles.editbox1,'String'); %name you entered in edit box
myfun = str2func(func_name); %turn the string into a function handle
myfun_output = myfun;
%some formatting of myfun_output here perhaps, for readability and to
% convert it to a string.
set(handles.listbox1,'String',myfun_output) %your listbox
guidata(hObject,handles)
Your main question, though, just seemed to be about being able to call the function from within your GUI's mfile. To do that, all you should have to do is call the function from within the button's callback. Depending on the needed inputs to your function, things could get a little more complicated, but the calling one function from another and saving the output part is relatively simple.

추가 답변 (1개)

mohamed
mohamed 2012년 12월 20일
Thank you so much for your fast reply

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by