1- function dydt = lagrang(~, y)2- syms m1 m2 m3 l1 l2 l3 g3- dydt = zeros(6,5,4,3,2,1);4- m1=1; m2=1; m3=1; l1=1; l2=1; l3=1; g=9.81;5- dydt(1)=y(2);6- dydt(3)=y(4);7- dydt(5)=y(6);8- dydt(1)*(l1^2*(m1+m2+m3))+dydt(3)((m2+m3)*l1*l2*cos(y(1)-y(3)))+dydt(5)*(m3*l1*l3*cos(y(1)-y(5)))=-(m2+m3)*l1*l2*y(4)^2*sin(y(1)-y(3))-m3*l1*l3*y(6)^2*sin(y(1)-y(5))-(m1+m2+m3)*g*l1*cos(y(1));9- dydt(1)*((m2+m3)*l1*l2*cos((y(1)-y(3))))+dydt(3)*(l2^2*(m2+m3))+dydt(5)*(m3*l2*l3*cos(y(3)-y(5)))=(m2+m3)*l1*l2*y(2)^2*sin(y(1)-y(3))-m3*l2*l3*y(6)^2*sin(y(3)-y(5))-(m2+m3)*g*l2*cos(y(3));10- dydt(1)*(m3*l1*l3*cos(y(1)-y(5)))+dydt(2)*m3*l2*l3*cos(y(3)-y(5))+dydt(l3^2*m3)=m3*l1*l3*y(2)^2*sin(y(1)-y(5))+m3*l2*l3*y(4)^2*sin(y(3)-y(5))-m3*g**l3*cos(y(5))%other part
dydt = [0; pi/2; 0; pi/2; 0; pi/2];[t1,y1] = ode45(@lagrang, [0 20], dydt);plot(t1,y1(:,2));
When I run this, I get a problem. Sorry if this is a simple problem to solve, since I am new to this program, it's been one week for me since i started.
Error: File: lagrang.m Line: 8 Column: 98The expression to the left of the equals sign is not a valid target for an assignment.Error in odearguments (line 90)f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);Error in lagrange_ans (line 2)[t1,y1] = ode45(@lagrang, [0 20], dydt);
The equations' itself:
Where do i go wrong?
Best Answer