Cases duplicated on menu Matlab

4 views (last 30 days)
Madalena Francisco
Madalena Francisco on 9 Jan 2023
Commented: Voss on 10 Jan 2023
%I´m building this program, and i repeat 'case 2' but it´s for 2 different
%menus I tried to change for a text name the cases to not repeat the '2', but I think that menu
%recognize just numbers... so I don´t know what I could do... appears a
%message error saying that the cases are duplicated
%the first case 2 it´s for b1 menu
% the other one it´s for a1 menu
%Thank u!
a1=menu({'This program allows the fitting of functions to experimental points.', ...
'To start the program, click on the Start button.'},'Start','Exit');
while a1<=2
switch a1
case 1
b1= menu('How do you intend to insert the experimental points?', ...
'By a file','Manually','Back','Exit');
switch b1
case 2
prompt2= {'How many experimental values do you want to input?'};
title = 'Number of experimental values';
numlines=1;
ret = {' '};
answer = inputdlg(prompt2,title,numlines,ret);
case 3
a1=menu({'This program allows the fitting of functions to experimental points.', ...
'To start the program, click on the Start button.'},'Start','Exit');
case 4
break
case 2
break
end
end
end

Accepted Answer

Voss
Voss on 10 Jan 2023
You need an "end" after "case 4, break" and before "case 2, break", to close out the "switch b1" block. And then you will need to delete one of the "end"s at the end.
switch a1
case 1
b1 = menu() % ...
switch b1
case 2
% ...
case 3
% ...
case 4
% ...
end % <- was missing
case 2
% ...
end
  2 Comments
Madalena Francisco
Madalena Francisco on 10 Jan 2023
Wow!!! It works!! Thanks a lot again Voss!! U saved my program!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!