The complete error message:
Index exceeds matrix dimensions.
Error in @(t,u,g,L)[u(2);-g/L*sin(u(1))]
Error in @(t,u)f(t,u,g,L)
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:});
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
The questioning is about a pendulum that have different starting values(10,30,....,170)of angle phi0. and I aren´t able to solv it. Thanks in advance :)
The code:
L=0.1; g=9.82;
phi0=linspace(10*pi/180,170*pi/180,9);
f=@(t,u,g,L)[u(2); -g/L*sin(u(1))];
tspan=linspace(0,1,200);
o=zeros(size(phi0));
u0=[phi0;o];
options=odeset('Events',@funevent);
for i=1:1
[t,U]=ode45(@(t,u)f(t,u,g,L),tspan,u0(i),options);
end
subplot(1,2,1), plot(t,U(:,1),'g')
subplot(1,2,2), plot(U(:,1),U(:,2),'g')
0 Comments
Sign in to comment.