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

A marathon is 42 kilometers. Runners like to calculate their average speed based

ID: 3809152 • Letter: A

Question

A marathon is 42 kilometers. Runners like to calculate their average speed based on the time they would like finish the marathon. Write a function called marathonSpeed that will accept a vector of different runners' target completion times in whole number of minutes; the function returns a vector of the average speed in kms/hour corresponding to each completion time. Call your function with a vector argument of at least three different completion times, and assign the returned valued to a variable call myAvgSpeed. If you were to add error checking, what error checking should you do on the argument? Create a test table and write matlab function to solve the problem. Design will be done in lecture or lab.

Explanation / Answer

function myfunc = marathonSpeed(t)

t(1)=t(1)/60

t(2)=t(2)/60

t(3)=t(3)/60

n=0

while(n<3)

myAvgSpeed = 42/t;

myfunc(n) = myAvgSpeed;

n=n+1;

end

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