Invalid expression. Need help fixing my function.

1 Ansicht (letzte 30 Tage)
Jacob Smith
Jacob Smith am 27 Feb. 2021
Kommentiert: Jacob Smith am 27 Feb. 2021
I am new to all of this and cant figure out what it is I am doing wrong. I've been at this for sometime now and I've looked at a lot of reference material and still I have nothing working for me. What error have I made and how can it be fixed? I'm going braindead over here, please and thank you! I've underlined the current trouble spot.
function grade = lettergrade(score)
if score < 0 "OR" score > 100
grade = 'incorrect input';
elseif score <= 90 && score <= 100
grade = 'A';
elseif score >= 80 && score <= 90
grade = 'B';
elseif score >= 70 && score < 80
grade = 'C';
elseif score >= 60 && score < 70
grade = 'D';
elseif score < 60
grade = 'F';
end
Error: File: lettergrade.m Line: 2 Column: 19
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of
parentheses.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 27 Feb. 2021
if score < 0 || score > 100
  5 Kommentare
Jacob Smith
Jacob Smith am 27 Feb. 2021
I think I'm smellin what you're cooking. Thanks for the help.
Jacob Smith
Jacob Smith am 27 Feb. 2021
Yep, everything is working as it should. Thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by