Nested Function Issue?
显示 更早的评论
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
2016-6-29
Please show the error message.
Jenna Domek
2016-6-29
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
2016-6-29
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.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
