Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: I'm new to matlab; why is this function wrong?
Replies: 5   Last Post: Dec 6, 2012 12:41 PM

 Messages: [ Previous | Next ]
 Alex Posts: 4 Registered: 12/6/12
Re: I'm new to matlab; why is this function wrong?
Posted: Dec 6, 2012 11:40 AM

The program now brings up a plot, but it's blank. It is supposed to plot an X in the middle and an orbit of green o's.

It also brings up this error: ??? Undefined function or method 'orbits' for input arguments of type 'double'.

Error in ==> two_dimensional_ac at 15
[R V] = orbits(Ro, Vo, del_t)

function [R V] = orbits(Ro, Vo, del_t)
Ro=[1.5e11, 0];
Vo=[0, 2*pi*Ro(1)/(365*24*60*60)];
del_t=24*3600;
G = 1.67e-11;
Ms = 1.97e30;
d = (Ro(1)^2 + Ro(2)^2)^(3/2);
a = -(G*Ms/d)* Ro;
V = Vo + a * del_t;
R = Ro + Vo * del_t + .5 * a * del_t^2;

for n = 1:1:730
plot(0,0,'yX')
hold on
[R V] = orbits(Ro, Vo, del_t) <----- Line 15 Error
plot(R(1),R(2),'go')
hold on;
Ro=R;
Vo=V;
end
end

Date Subject Author
12/6/12 Alex
12/6/12 Alex
12/6/12 Sargondjani
12/6/12 Alex
12/6/12 Sargondjani
12/6/12 Alex