Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Compare the read numbers with the stored minimum number x_min using if-statement. Using the following rules: o If the read number is less than the

image text in transcribedimage text in transcribed

Compare the read numbers with the stored minimum number x_min using if-statement. Using the following rules: o If the read number is less than the number in x_min, then: Update the minimum number x_min with the read number. o If the read number is equal to or greater than the stored minimum number, then continue reading the next number in the array. After finishing the for loop, assign the stored minimum number x_min to the output variable. i. 3. firstplace.m Create a MATLAB Program titled firstplace.m and open the file. Setup an output argument called outArg, and an input argument called inArg. Define a local variable named x_firstplace that will hold the student's number of the highest grade, initialize this variable to zero. Define a local variable named x_sum that will hold the highest grades, initialize this variable to zero. Define and initialize local variables named rowx and colx with the size of the input matrix. Use the for-loop to read all the rows in the input matrix. Define and initialize a local variable named row_sum with the sum of the read row. Compare row_sum with x_sum using if statement. Using the following rules: o If row_sum is less than x_sum, continue reading the array. o If row_sum is equal to or greater than x_sum, then do the following: Update x_sum with row_sum value. Update x_firstplace with the current row number (current index). After finishing the for loop, assign the student number in x_firstplace to the output variable. Sample Run: gr = 94 97 95 89 91 88 95 87 90 72 78 60 98 87 81 79 76 69 92 80 77 73 78 70 80 89 81 86 94 90 The Lowest grade in Math (first column) is : 72 The First Place student number is : 1 Main topics: If-Statement, Loops 1. Open MATLAB 1. Lab07.m Create a driver script file named Lab07.m Create the following matrix named gr, which contains the grades for 10 students for three different subjects (Math, English and Physics) with the following data: r94 97 957 89 91 88 95 87 90 72 78 60 98 87 81 gr = 79 76 69 92 80 77 73 78 70 80 89 81 186 94 901 Find the lowest grade in Math subject using for-loop and if-statement: o Extract the Math grades for all students, store the extracted data in a local variable called math o Call the function named min_for(), using the math variable as input and store the result of the function in a local variable called min_math. o Print the minimum grade in Math as shown in the Sample Run. Find the student that has the highest grades in the all subjects using a for-loop and if- statements: o Call the function named firstplace(), use the above gr matrix as an input and store the returned scalar value in a local variable called first place. o Print the first place's student number as shown in the Sample Run. 2. min_for.m Create a MATLAB Program titled min_for.m and open the file. Setup an output argument called outArg, and an input argument called inArg. Define a local variable named x_min that will hold the minimum number, initialize this variable with 100. Use the for-loop to read all the numbers in the input array

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

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

Students also viewed these Databases questions