I have a GUI that collects user data in the form of numbers. I want the user to hit the pushbutton in the GUI in order to run a function file(.m file) that uses the imputed data of the user to display results
My function file is dish.m
The GUI pushbutton function is this:
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
What code do i need to run.

 채택된 답변

Image Analyst
Image Analyst 2014년 1월 25일

1 개 추천

Call dish():
[out1, out2, out3] = dish(in1, in2); % or whatever arguments it has.

댓글 수: 4

Philip
Philip 2014년 1월 25일
Thank you. I have an error message. This is what I coded:
dish ();
[Er,h,Freq] = dish(Er,h,Freq); % Passing Er,h,Freq values to dish.m
% Er,h,Freq have already been called into the GUI function
An error message came in as this:
Error using dish (line 21)
Not enough input arguments.
...
Error while evaluating uicontrol Callback
The dish.m file starts like this:
function patchcfg=dish(Er,h,Freq)
...
Please where did i go wrong? Thank you.
Why did you call it twice, once with no input arguments? It says "Not enough input arguments." and tells you the exact line where it happened: dish(), so does that tell you anything?
Next, dish gives only one argument back: patchcfg, so you can't have it replace three variables (Er,h,Freq) - it can replace only 1, and you should give it different names than any of your input variables.
Try this:
patchConfiguration = dish(Er, h, Freq);
where you're passing in 3 input variables and receiving one output variable, just like what it expects, as you can see from the "function" definition line. Of course, in your calling routine, the variables can have different names than in the function definition, just like all computer languages. They can also be the same if you want.
Philip
Philip 2014년 1월 25일
Thank you very much @ Image Analyst.
Am grateful for you answer and time. This is the code I imputed and it worked fine.
dish(Er,h,Freq);
I realized it's because the dish.m function is receiving values, I need not make it dish ()
Thank you. My GUI is running fine now.
Image Analyst
Image Analyst 2014년 1월 25일
That's fine. You do not need to accept the values it returns if you don't plan on using them.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Holidays / Seasons에 대해 자세히 알아보기

질문:

2014년 1월 25일

댓글:

2014년 1월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by