ode45 solver not getting solved showing busy for indefinite time
Show older comments
The code is as follows:
function yd = myfunc2(t,y)
%theta1 = y(1) theta2 = y(2) theta1dot = y(3) theta2dot = y(4)
Kp1=0.0101;
Kp2=0.0101;
Kd1=-0.0189;
Kd2=-0.0189;
%Dynamic Solutions for trajectory case input as argument from the main code
q_traj_1=(pi/8)*(t)^2-(pi/24)*(t)^3;
q_traj_2=(pi/4)*(t)^2-(pi/12)*(t)^3;
u1 = Kp1*(q_traj_1-y(1)) - Kd1*y(1);
u2 = Kp2*(q_traj_2-y(2)) - Kd2*y(2);
yd(1)= y(3);
yd(2)= y(4);
yd(3) = (250*sin(y(2))*y(3)^2*y(4))/7 + (250*sin(y(2))*y(3)*y(4)^2)/7 + 7.2492*y(3) - 18.1230*y(4) - (1000*u1)/21 + (2500*u2)/21 - (4905*cos(y(1) + y(2)))/14 + (4905*cos(y(1)))/7;
yd(4)= (250*sin(y(2))*y(3)^2*y(4))/7 + (250*sin(y(2))*y(3)*y(4)^2)/7 - 18.1230*y(3) + 7.2492*y(4) + (2500*u1)/21 - (1000*u2)/21 - (4905*cos(y(1) + y(2)))/14 - (24525*cos(y(1)))/14;
yd=yd';
end
It is not getting solved with input arguments as t = [0 10] and y = [0 0 0 0]. Can anyone point out what is wrong here? TIA
Answers (1)
madhan ravi
on 4 Nov 2018
Edited: madhan ravi
on 4 Nov 2018
t = [0 10]
y0 = [0 0 0 0]
[t,y]= ode45(@myfunc2,t,y0); %function calling
plot(t,y(:,1),'r') %plots solution 1
figure
plot(t,y(:,2),'g') %plots solution 2
figure
plot(t,y(:,3),'b') %plots solution 3
figure
plot(t,y(:,4),'m') %plots solution 4
function yd = myfunc2(t,y)
%theta1 = y(1) theta2 = y(2) theta1dot = y(3) theta2dot = y(4)
Kp1=0.0101;
Kp2=0.0101;
Kd1=-0.0189;
Kd2=-0.0189;
%Dynamic Solutions for trajectory case input as argument from the main code
q_traj_1=(pi/8)*(t)^2-(pi/24)*(t)^3;
q_traj_2=(pi/4)*(t)^2-(pi/12)*(t)^3;
u1 = Kp1*(q_traj_1-y(1)) - Kd1*y(1);
u2 = Kp2*(q_traj_2-y(2)) - Kd2*y(2);
yd(1)= y(3);
yd(2)= y(4);
yd(3) = (250*sin(y(2))*y(3)^2*y(4))/7 + (250*sin(y(2))*y(3)*y(4)^2)/7 + 7.2492*y(3) - 18.1230*y(4) - (1000*u1)/21 + (2500*u2)/21 - (4905*cos(y(1) + y(2)))/14 + (4905*cos(y(1)))/7;
yd(4)= (250*sin(y(2))*y(3)^2*y(4))/7 + (250*sin(y(2))*y(3)*y(4)^2)/7 - 18.1230*y(3) + 7.2492*y(4) + (2500*u1)/21 - (1000*u2)/21 - (4905*cos(y(1) + y(2)))/14 - (24525*cos(y(1)))/14;
yd=[yd(1);yd(2);yd(3);yd(1)]; %always make a column vector
end
1 Comment
Srikesh Iyer
on 4 Nov 2018
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!