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.

 Akzeptierte Antwort

Image Analyst
Image Analyst am 25 Jan. 2014

1 Stimme

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

4 Kommentare

Philip
Philip am 25 Jan. 2014
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 am 25 Jan. 2014
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 am 25 Jan. 2014
That's fine. You do not need to accept the values it returns if you don't plan on using them.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Holidays / Seasons finden Sie in Hilfe-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