From the course: Learning MATLAB

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Solution: Write your first program

Solution: Write your first program - MATLAB Tutorial

From the course: Learning MATLAB

Solution: Write your first program

- [Narrator] I hope you had fun with those challenges. Let's take a look at how I solved them. So the first challenge is about finding the number of students that are failing and passing in a course. So let's create a new script file. So we'll go to new script and we are going to type the description to explain what is the purpose of this program, which is calculating the number of students failing and passing in a course, so calculate number of students failing and passing. Let's create an array called grades, as follows, and we put semicolon to suppress the output. This array, as you can see, contains the grades of the 20 students. Since we have to count total number of failures, we start with a variable called n, which is equal to zero, suppress the output, and then the variable m, which will be counting total number of passing students. So that's m = 0 and suppress the output. We are going to start the program using the for…

Contents