Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In MatLab I have to create the following functions: Create a function that calcu

ID: 671985 • Letter: I

Question

In MatLab I have to create the following functions:

Create a function that calculates Target Heart Rate (THR = ( 220 – Age) * 0.6).

The function header should take 1 argument which is the age:

function return_variable_name = function_name(Age)

The function should have 1 more line to do the calculation and to set the result equal to return_variable_name.

Save the function to a script file. Script name should be the same as the function name.

Run the function from the command line with the input argument (21).

Use your own descriptive names in place of “function_return_variable” and “function_name”

Then make a new script to ask a user to enter an age. Then use the age to call the Target Heart Rate function above.

New script. (example runTHR.m)

Ask the user to input an age using the function, input().

Use this age to call the THR function from above, and calculate THR.

Display the calculated THR to the console.

Explanation / Answer

Function Target_heart_rate.m

function THR=Target_heart_rate(age)
THR=(220-age)*0.6;
end

Script file: Target_run.m

age=input('enter the value of age')
Target_heart_rate(age)

OUTPUT:

>> Target_run
enter the value of age21

age =

    21


ans =

  119.4000

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote