MATLAB: Trying to open a new pannel when checkboxes are filled but dont work

checkboxesnew pannel

Hello guys, here I am trying to create a gui with different checkbox associated with a measurement. you hae 2 main cheboxes. Each of them have specefic checkboxes that are available to be filled with a value. If measurements are missing (depending if the first or second cehcbox is selected), I want to open a msgbox that tells to go back. If the statements are met, i want to open a new pannel.
Tahnk you in advance!
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
L = str2double(get(handles.editL,'String'));
G = str2double(get(handles.editG,'String'));
W = str2double(get(handles.editW,'String'));
S = str2double(get(handles.editS, 'String'));
C = str2double(get(handles.editC,'String'));
H = str2double(get(handles.editH,'String'));
checkboxgable = get(handles.checkboxStatus2,'Value');
checkboxtunnel = get(handles.checkboxStatus1,'Value');
switch checkboxgable
case checkboxgable == 1
if isempty(L)
disp('There is no valid values for the length of the house (L)');
elseif isempty(G)
disp('There is no valid values for the height (G)');
elseif isempty(W)
disp('There is no valid values for the width');
elseif isempty(S)
disp('There is no valid values for the length of roof (S)');
elseif isempty(H)
disp('There is no valid values for the Total height (h)');
end
case checkboxgable == 0 && checkbotunnel == 0
disp('you cannot continue without filling the required measurements')
case checkboxtunnel == 1
if isempty(L)
disp('There is no valid values for the length of the house (L)');
elseif isempty(W)
disp('There is no valid values for the width (W)');
elseif isempty(H)
disp('There is no valid values for the total height (h)');
elseif isempty(C)
disp('There is no valid values for the length of roof (C)');
end
otherwise
window2
end

Best Answer

You are treating your case statements as if they are conditions
case checkboxgable == 1
or
case checkboxgable == 0 && checkbotunnel == 0
I think that using if and elseif would be more suitable for this type of work. For example
if checkboxgable == 1
% do something
elseif checkboxgable == 0 && checkbotunnel == 0
% do something else
elseif checkboxtunnel == 1
% etc.

else
% etc.
end
See switch for details on use of this expression type.
Related Question