Dynamic popup menu choices in GUIDE
Show older comments
I am attempting to make dynamic popup menu fields in a GUI made with GUIDE.
My intention is to change the fields when a specific popup choice is picked in another popup menu. The popup menus are initially populated with information from GUIDEs Property Inspector.
This codes works when launching the GUI using after pressing the "play" button in GUIDE. It does not work when launching the figure on its own.
- * *The error received is "Attempt to reference field of non-structure array."
Why does this happen? How can I make it work like it works when launched from GUIDE?* * *
The relevant code; solver_settings doesn't do anything interesting. From this it can be seen that the intention is to have a certain range of algorithm options available to the user depending on what solver type he picks, because not all of them are relevant to each other. Hence L-M would not be available to fmincon or Genetic Algorithm.
function solver_type_Callback(hObject, eventdata, handles)
% hObject handle to solver_type (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns solver_type contents as cell array
% contents{get(hObject,'Value')} returns selected item from solver_type
set1 = {'interior-point';'active-set';'sqp';'trust-region-reflective'};
set2 = {'trust-region-reflective','levenberg-marquardt'};
set3 = {'In progress'};
val = get(hObject,'Value');
str = get(hObject,'String');
switch str{val}
case 'fmincon'
assignin('base','optimalg',1);
set(handles.solver_settings,'String',set1,'Value',1);
case 'lsqnonlin'
assignin('base','optimalg',2);
set(handles.solver_settings,'String',set2,'Value',1);
case 'Genetic Algorithm'
assignin('base','optimalg',3);
set(handles.solver_settings,'String',set3,'Value',1);
end
guidata(hObject, handles)
1 Comment
Sara
on 14 Jan 2015
Does matlab give you the line where the error occur? What does that line say in case?
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!