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 ExchangeMATLAB についてさらに検索

質問済み:

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