Hi every one. I am going to create a function which has following specification. Write a function called light_time that takes as input a row vector of distances in miles 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 92.9 million miles away. The second output contains the input distances converted to kilometers. Assume that the speed of light is 300,000 km/s and that one mile equals 1.609 km. I am using that code
function [time,distance]=light_time(dis) for i=1:length(dis) time(i)=1/92.9*dis(i) distance(i)=1.609*dis(i) end endbut getting time and distance every time the for loop run.I want to gets two vectors in final output which show the time and distance travel by the light.Guide me where i set my code to get two final vectors.Thanks in advance.......
Best Answer