I am getting an error in my code. I have no idea why it is giving an error. I am building a GUI in matlab. I am using the following code:
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 = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
contents=cellstr(get(hObject,'String'));
a=contents{get(hObject,'Value')};
if a=='CRI'
b=1
end
if
a=='GAI'
b=2
end
if
a=='CQS'
b=3
end
handles.indices=b;
guidata(hObject,handles);
when I use this, I am not getting any error. but when I increase my code to the following:
% --- 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 = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
contents=cellstr(get(hObject,'String'))
a=contents{get(hObject,'Value')}
if
a=='CRI'
b=1
end
if
a=='GAI'
b=2
end
if
a=='CQS'
b=3
end
if
a=='CRI-CAM02UCS'
b=4
end
if
a=='nCRI'
b=5
end
if
a=='Luminous Efficacy'
b=6
end
handles.indices=b;
guidata(hObject,handles);
The error that I get is:
Error using ==
Matrix dimensions must agree.
Error in input_spd>popupmenu1_Callback (line 108)
if a=='CRI-CAM02UCS'
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in input_spd (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)input_spd('popupmenu1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback