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 commentaires

José-Luis
José-Luis le 29 Juin 2016
Please show the error message.
Jenna Domek
Jenna Domek le 29 Juin 2016
José-Luis
José-Luis le 29 Juin 2016
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 le 29 Juin 2016
I don't see where! My only function is before the switch statement.
José-Luis
José-Luis le 29 Juin 2016
To find out where, please use the debugger.
This should also work:
dbstop if error
and then run your program.

Connectez-vous pour commenter.

 Réponse acceptée

Jenna Domek
Jenna Domek le 29 Juin 2016

0 votes

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

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by