Can you please help me out with the error in following program

3 次查看(过去 30 天)
x=input('Enter the marks');
switch (x)
case {x>=90 && x<=100}
disp('O');
case {x>=80 && x<=89}
disp('A+')
case {x>=70 && x<=79}
disp('A');
case {x>=60 && x<=69}
disp('B+');
case {x>=50 && x<=59}
disp('B');
case {x>=40 && x<=49}
disp('c');
case {x<40}
disp('F');
otherwise
disp('No grade')
end

回答(1 个)

Abdul Rehman
Abdul Rehman 2018-10-27
Aditi.. Error is very simple
Basically && Operator in matlab perform Logical Operation.
You simply have to replace the && with &.
if true
x=input('Enter the marks');
switch (x)
case {x>=90 & x<=100}
disp('O');
case {x>=80 & x<=89}
disp('A+')
case {x>=70 & x<=79}
disp('A');
case {x>=60 & x<=69}
disp('B+');
case {x>=50 & x<=59}
disp('B');
case {x>=40 & x<=49}
disp('c');
case {x<40}
disp('F');
otherwise
disp('No grade')
end
end
Hopefully it's work for you..Thanks

类别

Help CenterFile Exchange 中查找有关 Entering Commands 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by