Section 15.6 A Final Note on Loops
Look, I get it. Programming is hard. Loops are hard. But remember that we are treating this as a brain workout. No one walks into a gym and expects to bench 500lbs right away! You need to work out for years before you get to that level. The good thing about programming, you do not need to practice for years to understand loops! You will need to practice though.
The other thing to remember is that not everyone is equal. Just like working out, some of your classmates or peers may get this faster than you. It doesnβt matter. The only thing that matters is YOU. You need to take the time necessary to understand these concepts. I believe in you!
Challenge Question- Return to the Student Grade Analyzer
Speaking of practice, here is one last challenge question to end the chapter with. Remember the last chapter when we used decisions to assign a letter grade to a numeric grade? Now consider the case where instead of a single numeric grade, you instead have an array of grades. Letβs say that we have an array called
grades that is a column vector that contains the final grades for everyone in a class. When you are working on this, only consider 10 or so grades but understand that your algorithm should work for any number of grades (my classes can often be 200+ students!).

Can you create a MATLAB script that:
-
Accepts a 1D row vector called
gradethat contains numeric grades. -
gradecan have any number of grade entries. -
Upon completion, your script creates a corresponding 1D row vector called
letter_gradearray. The index of the arrays matches, so ifgrades(2) = 92, letter_grades(2) = 'A'
Good luck practicing! Remember our mantra and guiding process for writing complex programs is: think, sketch, code, test, repeat.
You have attempted of activities on this page.
