Passing Variables from GUI to Script

4 次查看(过去 30 天)
Hello All. I have built an analysis tool that boots up to a UI with dropdown menus. The 'Run PME Analysis' button runs a script with a SQL query that is generated from values in the dropdowns ("run_pme").
But, I have been unable to pass variables from the GUI dropdowns to my script. Here is the code from the top dropdown and the first bit of code from the script:
if true
function popfirm_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
firmcontents = cellstr(get(hObject,'String'));
firm = firmcontents{get(hObject,'Value')};
if (strcmp(firm,'All Firms'))
firmquery = '';
else
firmquery = strcat('AND [Firm] ='," '", firm, "'");
end
handles.firmquery = 'firmquery';
guidata(hObject, handles);
if true
function popfirm_Callback(hObject, eventdata, handles)
firmcontents = cellstr(get(hObject,'String'));
firm = firmcontents{get(hObject,'Value')};
if (strcmp(firm,'All Firms'))
firmquery = '';
else
firmquery = strcat('AND [Firm] ='," '", firm, "'");
end
handles.firmquery = 'firmquery';
guidata(hObject, handles);
end
if true
function run_pme(obj, eventData, handles)
firmq = handles.firmquery
end
When I click the "Run PME" Button, I get the following error:
_Not enough input arguments.
Error in PME_Analysis_Full>run_pme (line 206) firmq = handles.firmquery_
I'm sure the problem will be obvious to anyone with experience but I'm still quite new. Any help you can provide would be most appreciated.
Thanks!
  2 个评论
Adam
Adam 2017-10-13
How is run_pme called? Is it the callback for the button that you renamed to not include the usual 'callback' part of its name?
junkbond916
junkbond916 2017-10-13
Sorry - I should have included the code for the "Run PME Analysis" button. Here you go:
if true
function runpmebutton_Callback(hObject, eventdata, handles)
run_pme;
end

请先登录,再进行评论。

采纳的回答

Rajesh Balagam
Rajesh Balagam 2017-10-16
Refer to the following MATLAB documentation page for some pointers on sharing the data among UI elements.
It seems the error observed in your code is due to calling run_pme function with no input arguments whereas the run_pme function expects 3 inputs.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by