I'm getting a nested function error in my code and I'm not quite sure why. I don't have the function in my for loop or in an if/else if statement. The main goal of the code is to ask the user what type of file they want read in out of the 4 options, ask how many files of that type are being read in and then ultimately displaying the data from the files in a 3D plane. Note: some of my code is straight from an example, but it shouldn't matter.
bg1 = uibuttongroup ('Visible', 'on');
bg1.Position = [.35 .45 .15 .275];
gpxbutton = uicontrol('Style', 'radio', 'String', 'gpx', 'Position',[200 275 50 30]);
csvbutton = uicontrol('Style', 'radio', 'String', 'csv', 'Position',[200 250 50 30]);
excelbutton = uicontrol('Style', 'radio', 'String', 'excel', 'Position',[200 225 50 30]);
kmlbutton = uicontrol('Style', 'radio', 'String', 'kml','Position',[200 200 50 30]);
function uibuttongroup1_SelectionChangedFcn(hObject, eventdata, handles)
% hObject handle to the selected object in uibuttongroup1
% eventdata structure with the following fields
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object.
case 'radiobutton1'
display('Radio button 1');
case 'radiobutton2'
display('Radio button 2');
case 'togglebutton1'
display('Toggle button 1');
case 'togglebutton2'
display('Toggle button 2');
end
If there are any other comments or suggestions I'd appreciate those as well.
Thanks, JD

댓글 수: 5

José-Luis
José-Luis 2016년 6월 29일
Please show the error message.
Jenna Domek
Jenna Domek 2016년 6월 29일
José-Luis
José-Luis 2016년 6월 29일
Well, it seems you have defined a function inside a control statement. Don't do that.
Define that function somewhere else in the file and only call it inside the statement.
Jenna Domek
Jenna Domek 2016년 6월 29일
I don't see where! My only function is before the switch statement.
José-Luis
José-Luis 2016년 6월 29일
To find out where, please use the debugger.
This should also work:
dbstop if error
and then run your program.

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

 채택된 답변

Jenna Domek
Jenna Domek 2016년 6월 29일

0 개 추천

I solved my own problem, go me!
function maingps
bg1 = uibuttongroup ('Visible', 'on');
bg1.Position = [.35 .45 .15 .275];
gpxbutton = uicontrol('Style', 'radio', 'String', 'gpx', 'Position',[200 275 50 30]);
csvbutton = uicontrol('Style', 'radio', 'String', 'csv', 'Position',[200 250 50 30]);
excelbutton = uicontrol('Style', 'radio', 'String', 'excel', 'Position',[200 225 50 30]);
kmlbutton = uicontrol('Style', 'radio', 'String', 'kml','Position',[200 200 50 30]);
end
function uibuttongroup1_SelectionChangedFcn(hObject, eventdata, handles)
% hObject handle to the selected object in uibuttongroup1
% eventdata structure with the following fields
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object.
case 'radiobutton1'
display('Radio button 1');
case 'radiobutton2'
display('Radio button 2');
case 'togglebutton1'
display('Toggle button 1');
case 'togglebutton2'
display('Toggle button 2');
end
end
thanks

추가 답변 (0개)

카테고리

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

질문:

2016년 6월 29일

답변:

2016년 6월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by