Write a function called lightspeed that takes as input a row
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.
(You can not use if, if else, or any types of loops to solve)
Solution
%function defintion
------------------------------------------------------------------------------------------------------
Sample output:
dis is vector that contains distances
from earth to moon=384000
sun to earth=1.496e8
sun to mars=2.2794e8
-----------------------------------------------------------
From the matlab command line,
Create a distance vector with name distance
--> distance = [384000 1.496e8 2.2794e8];
 --> [time,distance]=light_time(distance)
 time =
     0.0213    8.3111   12.6633
 distance =
     617856 240706400 366755460

