Error in my matlab code : Operands to the || and && operators must be convertible to logical scalar values

Hello everyone,

I wrote a code to calculate the final letter grades of students; however, I keep encountering this error whenever I run it. I know that we should use && with a scalar value however, the grades for 20 students are in a 20x1 double matrix called Final. How can I fix this issue so that it looks at each students grade and assigns it a letter. The code is :

if Final>=80

letter='A';

elseif Final>=70 && Final=60 && Final=50 && Final
5 comments
share
save
hide
report
50% Upvoted
This thread is archived
New comments cannot be posted and votes cannot be cast
Sort by: best



level 1
· 3y
+5
What you want to do is use logical indexing.

You are watching: Operands to the || and && operators must be convertible to logical scalar values.


4
Share
ReportSave
level 2
Op · 3y

Thank you for your help!


1
Share
ReportSave
level 1
· 3y

The double && and || are called short-circuit operators and only work on logicals.

You can do this without an if statement.

See more: 303 2Nd St San Francisco Ca 94107, 303 2Nd Street Plaza


2
Share
ReportSave
level 2
Op · 3y

Thank you! I actually ended up using an If statement. I just changed some code before the one above.


1
Share
ReportSave
More posts from the matlab community
Continue browsing in r/matlab


*

r/matlab
Official MATLAB subdiscoverhotmail.com
42.0k
coders


39

logged in


Created Aug 15, 2009
Join
*
*
*
*

*

Top posts november 10th 2018Top posts of november, 2018Top posts 2018
helpdiscoverhotmail.com coinsdiscoverhotmail.com premiumdiscoverhotmail.com gifts
aboutcareerspressadvertiseblogTermsContent policyPrivacy policyMod policy
Back to Top