Passing Variables from GUI to Script
조회 수: 3 (최근 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
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?
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!