Whay this code showing error?

1 view (last 30 days)
Purvil Patel
Purvil Patel on 30 Apr 2017
Answered: Santhana Raj on 3 May 2017
function [ time1,dist2 ] = light_speed(distances)
time1 = ((distances)./18000000);
dist2 = ((distances).*0.6215);
as you asked for my code I gave you just to see if some thing is wrong because I am getting correct answer but it is not running To get one row vector indicating time in minute to travel light to earth according to input distance vector. and 2nd output is distance converted into miles respectively input distance vector in kilometer.
  2 Comments
Jan
Jan on 3 May 2017
@Purvil: I've formatted your code this time. Please use the "{} Code" button in the future. Thanks.
What does the tag "ans is correct but showing that incorrect with 150000000." mean? It sounds like the answer is correct, but wrong.

Sign in to comment.

Answers (1)

Santhana Raj
Santhana Raj on 3 May 2017
The multiplication and division numbers are wrong. Try this instead:
time1 = ((distances)./(60*3e8));
dist2 = ((distances).*0.62137);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!