I know this is an invalid expression on line 9. How can I correct this error? Also, what error is this exactly? Matlab displayed multiple possibilities when trying to correct it.

1 view (last 30 days)
clc
clear
x=input('Please enter a number:');
switch x
case 0
disp("You have entered 0");
case 2
disp("Your number is even and prime.");
case (3 5 7)
disp("Your number is prime");
otherwise
disp("Invalid number");
end

Accepted Answer

per isakson
per isakson on 3 Dec 2018
Edited: per isakson on 3 Dec 2018
Replace
case (3 5 7)
by
case {3,5,7}
With curly brackets
"what error is this" It's break the switch-case-otherwise syntax

More Answers (0)

Tags

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!