jsethuraman
Newbie level 1
- Joined
- Aug 20, 2013
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 11
I have problem in the following. I have written code for 'swinging Atwood machine' with RK method using ode23. The error message is 'exceed the recursion limit of 500'. Do I need to initialize y also?
function dy=swing1(t,y)
% Now this program is working.
mu=15;g=9.8;
%y(1)=r; y(2)=dy(1)/dt=rdot; dy(2)/dt=rdoubledot;
%y(3)=theta; y(4)=dy(3)/dt=thetadot; dy(4)/dt=thetadoubledot;
%y(1)=r; y(2)=rdot; y(3)=theta; y(4)=thetadot;
%there are only two output variables; dy(1) and dy(2);
dy=zeros(4,1);% Initialization of y's as zeors. Later they are filled %with%values created.
dy(1)=y(2);
dy(3)=y(4);
dy(2)=(1/(1+mu))*((y(1))*(y(4)^2)-g*(sin(y(3)-mu)));
dy(4)=-1*((2*(y(2))*(y(4))/y(1))+(g*sin(y(3)))/y(1));
y0=[1-eps eps pi+0.01 eps];
tspan=(1:0.01:4*pi);
[t,y]=ode23(@swing1,tspan,y0);
plot(t,y,1));
figure,plot(t,y,3));
figure, plot(y,3),y,1));
figure, plot(y,3),y,1));
end
function dy=swing1(t,y)
% Now this program is working.
mu=15;g=9.8;
%y(1)=r; y(2)=dy(1)/dt=rdot; dy(2)/dt=rdoubledot;
%y(3)=theta; y(4)=dy(3)/dt=thetadot; dy(4)/dt=thetadoubledot;
%y(1)=r; y(2)=rdot; y(3)=theta; y(4)=thetadot;
%there are only two output variables; dy(1) and dy(2);
dy=zeros(4,1);% Initialization of y's as zeors. Later they are filled %with%values created.
dy(1)=y(2);
dy(3)=y(4);
dy(2)=(1/(1+mu))*((y(1))*(y(4)^2)-g*(sin(y(3)-mu)));
dy(4)=-1*((2*(y(2))*(y(4))/y(1))+(g*sin(y(3)))/y(1));
y0=[1-eps eps pi+0.01 eps];
tspan=(1:0.01:4*pi);
[t,y]=ode23(@swing1,tspan,y0);
plot(t,y,1));
figure,plot(t,y,3));
figure, plot(y,3),y,1));
figure, plot(y,3),y,1));
end