Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Alex

Posts: 4
Registered: 12/6/12
I'm new to matlab; why is this function wrong?
Posted: Dec 6, 2012 11:22 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I'm getting the following error:
Error: File: two_dimensional_ac.m Line: 4 Column: 1
Function definitions are not permitted in this context.
Code:
plot(0,0,'yX')
hold on

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
[r v] = orbits(ro, vo, del_t)
plot(r(1),r(2),'go')
hold on;
ro=r;
vo=v;
end;

Thank you!





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.