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
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.