Question: Create array arr using these commands ( type them exactly ) : r n g ( 1 ) arr = 1 8 + 5 *

Create array arr using these commands (type them exactly):
rng(1)
arr=18+5**randn(1,10+randi(15))
Write and call local function CalculateAverage to calculate the average value averA of the array arr.
Mathematically, average (x) is defined as:
x=k=1NxkN
sum of all array elements divided by the number of elements N
The function CalculateAverage must have arr as input argument and averA as output argument. In the
function, determine the number of elements in the array (use length function). Then, use for loop to
calculate a sum of all array elements. Divide the sum by the number of elements to find the array average.
Write and call local function CalculateMin to calculate the minimum value minA of the array arr. The
function must have arr as input argument and minA as output argument. In the function, determine the
number of array elements. Initialize minA by assigning it a very large value, e.g., of positive infinity. Then,
use the for loop to go through all elements of the array arr, one after another. Inside the for loop, use the
if-construct to determine whether the current array element is smaller than the value of minA. If it is,
make it a new value of minA.
Print the array average and minimum values with 2 digits after decimal point using fprintf; include
description of the variables.
Organize your script in Input, Calculations, and Output sections. Include cleaning commands; provide
comments; suppress intermediate output. Use only those Matlab methods that were described in class.
Create array arr using these commands ( type them

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!