Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please solve this Matlab question. There is nothing missing in the question, this is what I am provided with too. For loop - Iteratively Calling

Please solve this Matlab question. There is nothing missing in the question, this is what I am provided with too.

image text in transcribed

image text in transcribedimage text in transcribed

For loop - Iteratively Calling a Function O solutions submitted (max: 10) One of the best uses for loops in coding is to iteratively execute algorithmic functions. In this problem you are given a pre-built function called "PassFail" that will input a scalar grade between 0-100 and output a 1 if the student has passed and a 0 if the student has failed. You are also given a grade book with 50 student grades in it that need to be evaluated with this function. To accomplish this, please perform the following tasks below: 1. Separate the Gradebook data (Now saved as a matrix called A) into column vectors. The first column should be called StuNumber, the second should be StuGrade. 2. Use a the function PassFail embedded in a for loop to create a column vector called "AllGrades". "AllGrades" should be a 50x1 vector of 1's and O's if done correctly. 1 A=readmatrix('Gradebook.xlsx'); %Reads in a 25 x 2 Matrix of student grades. Column 1 is the student #, Column 2 is the grade on 3 %Your Code here 9 10 11 12 -Instructor Generated Code- 13 %% Plotting the results 14 % You don't have to do anything with this. I just wanted you to have 15 % something pretty to look at when you got the answer :D 16 PctPass=sum(AllGrades)/length(AllGrades); 17 PctFail=1-PctPass; 18 19 pie( [PctPass, PctFail]) 20 legend({ 'Pass', 'Fail'}) 21 22 -The PassFail Function- 23 % Just for your reference 24 function [y] = PassFail(x) 25 % x= The student grade on a scale of 0-100 26 % y= A text output of whether or not the student has passed or failed 27 g If passed y= 1 28 % If failed y= 0 29 65 and above is passing 30 if x>=65 31 y=1; 32 else 33 y=0; 34 end StuNumber Calculated Correctly StuGrade Calculated Correctly AllGrades Calculated Correctly

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

More Books

Students also viewed these Databases questions

Question

12-5 How will MIS help my career?

Answered: 1 week ago