How to continue an if statement after using the switch function
Show older comments
I imbedded a switch function into an if statement but I'm finding it hard to nest my next if statment to the previous one.If you run this code it will only work half way.
In this code use the number 332837840 (when asked to type in:)
% scd must be a 9 digit number.
scd = input('Type in: ','S');
conDIG = scd - '0';%converting to digits
scued =(conDIG(1)*conDIG(3))-conDIG(5);
if scued > 7 || scued < 1
disp('De')
else
switch scued
case 1
disp('M')
case 2
disp('T')
case 3
disp('W')
case 4
disp ('T')
case 5
disp ('F')
case 6
disp ('S')
case 7
disp ('S')
otherwise
disp('A')
if scued > 7 || scued < 1
mpt = conDIG(2)*conDIG(4)- conDIG(6);
else
disp('De')
if mod(mpt,3) ~= 0
rendzP = conDIG(8)- conDIG(9);
else
rendzP = conDIG(7)- conDIG(9);
if rendzP > 7 || rendzP < 1
disp('De')
else
switch rendzP
case 1
disp('b')
case 2
disp('l')
case 3
disp('r')
case 4
disp('a')
case 5
disp('b')
case 6
disp('l')
case 7
disp('D')
otherwise
disp('De.')
end
end
end
end
end
end
Accepted Answer
More Answers (0)
Categories
Find more on RF Network Construction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!