Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
Aditi Rathore
Aditi Rathore el 27 de Oct. de 2018
Respondida: Abdul Rehman el 27 de Oct. de 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

Respuestas (1)

Abdul Rehman
Abdul Rehman el 27 de Oct. de 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

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by