From: hussein on
hi everyone ..
I have asked last month how to use the structure in the
Popupmenu and ithx to matt dash he gave me this answer
H= struct('Regler',...
struct('PD',...
struct('regelgroesse',...
char('DeltaN mit standard Aktivierung ',...
'DeltaN mit Fusionierung','Dynamische Schwelle'),...
'referenz',...
char ('v_ref' ,'DN_ref' ,'beide' ,'keine')),...
'KEINE',''),...
'Adaption','',...
'Simlationsmodell','',...
'Kalman','',...
'Fahrer','',...
'Szenario','');


stringlist=fieldnames(H.Regler);
set(handles.popupmenu1,'string',stringlist);






And modify your callback as follows:

% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version
of MATLAB
% handles structure with handles and user data (see
GUIDATA)


choices=get(hObject,'string');
selected=choices{get(hObject,'value')};

switch (selected)
case ('PD')
assignin('base','regler',1);
case('KEINE')
assignin('base','regler',2);
end



HOWEVER:
for this simple case where you want to assign the number of
the selected choice to a variable, you can achieve the same
result by simply using this callback:

% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version
of MATLAB
% handles structure with handles and user data (see
GUIDATA)

assignin('base','regler',get(hObject,'value'));


%this avoids any need for a switch statement.

it worked But WHAT i wanted to ask can i use a more
complex sructure not only to assign one variable but more
than one and also be capable to open another GUI by
chosing one of the fields .

thx for the help and if u could give me a site for
information or a book on the subject i would be
greatfull .. thx for any help