Bonjour tout le monde,

Je suis en train d'essayer de commander mon modèle simulink par l'intermédiaire d'une interface graphique. Seulement j'ai un problème avec un pop-up menu et les radio button.
En fait, je veux dans un premier temps choisir entre un échelon de température ou une consigne fixe. J'utilise donc 2 radio button pour faire le choix puis un pop-up menu pour choisir la valeur de la température. Voici mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
 
% --- Executes during object creation, after setting all properties.
function TEXT_CreateFcn(hObject, eventdata, handles)
% hObject    handle to TEXT (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
switch get(hObject,'Tag')   
    case 'Echelon'
set_param('Habitation/Choix','Value',0)
    case 'unique'
set_param('Habitation/Choix','Value',1)
 
end
 
% --- 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)
 
% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1
 
str = get(hObject, 'String');
val = get(hObject,'Value');
switch str{val};
case '-15' 
  NewStrVal = -15;
case '-14' 
  NewStrVal = -14;
case '-13' 
  NewStrVal = -13;
case '-12' 
  NewStrVal = -12;
case '-11' 
  NewStrVal = -11;
case '-10' 
  NewStrVal = -10;
case '-9' 
  NewStrVal = -9;
case '-8' 
  NewStrVal = -8;
case '-7' 
  NewStrVal = -7;
case '-6' 
  NewStrVal = -6;
case '-5' 
  NewStrVal = -5;
case '-4' 
  NewStrVal = -4;
case '-3' 
  NewStrVal = -3;
case '-2' 
  NewStrVal = -2;
case '-1' 
  NewStrVal = -1;
case '0' 
  NewStrVal = 0;
case '1' 
  NewStrVal = 1;
case '2' 
  NewStrVal = 2;
case '3' 
  NewStrVal = 3;
case '4' 
  NewStrVal = 4;
case '5' 
  NewStrVal =5;
case '6' 
  NewStrVal = 6;
case '7' 
  NewStrVal = 7;
case '8' 
  NewStrVal = 8;
case '9' 
  NewStrVal = 9;
case '10' 
  NewStrVal = 10;
case '11' 
  NewStrVal = 11;
case '12' 
  NewStrVal = 12;
case '13' 
  NewStrVal = 13;
case '14' 
  NewStrVal = 14;
case '15' 
  NewStrVal = 15;
case '16' 
  NewStrVal = 16;
case '17' 
  NewStrVal = 17;
case '18' 
  NewStrVal = 18;
case '19' 
  NewStrVal = 19;
case '20' 
  NewStrVal = 20;
 
end
 
NewVal = str2double(NewStrVal);
 
set(handles.popupmenu1,'string',NewVal)
 
set_param('Habitation/Text','Value',NewStrVal) 
 
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
 
% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
 
end
et voici le message d'erreur.

??? Cell contents reference from a non-cell array object.

Error in ==> test>popupmenu1_Callback at 432
switch str{val};

432 switch str{val};
Quelqu'un a t-il une idée svp ?!