Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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

Risposte (1)

Abdul Rehman
Abdul Rehman il 27 Ott 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

Categorie

Scopri di più su Entering Commands in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by