Write a function called light_speed that takes as input a row vector of distance
ID: 2291314 • Letter: W
Question
Write a function called light_speed that takes as input a row vector of distances in kilometers and returns two row vectors of the same length. Each element of the first output argument is the time in minutes that light would take to travel the distance specified by the corresponding element of the input vector. To check your math, it takes a little more than 8 minutes for sunlight to reach Earth which is 150 million kilometers away. The second output contains the input distances converted to miles. Assume that the speed of light is 300,000 km/s and that one mile equals 1.609 km.
Explanation / Answer
Matlab script:
function [t dm] = light_speed(dk)
t = (dk/3e5)/60; %gives time in minutes
dm = dk/1.609; %gives distance in miles
end
output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.