Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Aditi Rathore
Aditi Rathore le 27 Oct 2018
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

Réponses (1)

Abdul Rehman
Abdul Rehman le 27 Oct 2018
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

Catégories

En savoir plus sur Entering Commands dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by