clearclcmonth = input('Enter numerical value of month');switch month case {9, 4, 6, 11} days = 30; case 2 answer = input('leap year (yes/no)', 's'); leapYear = (answer(1) == 'y'); if leapYear days = 29; else days = 28; end case {1, 3, 5, 7, 8, 10, 12} days = 31; otherwise error('bad month index')end
MATLAB: Is there a more simple way to express this? How to simplify everything under “case 2”? Is there an alternative to writing out everything under case 2
MATLABswitch case
Best Answer