Is there anything wrong with my code? It's about the non linear pendulum

1 vue (au cours des 30 derniers jours)
KLETECH MOTORSPORTS
KLETECH MOTORSPORTS le 7 Nov 2020
Commenté : Rik le 7 Nov 2020
Just wondering if the placement of wsq is correct here?
i've put the values of L, L1, and d in th script.
pend_cn
functionydot = pend_cn(t2,y) %for non linear
wsq = (12*9.81*L)/(4*L^.2)+(d.^2)-(12*L*L1)+(12*L1.^2);
ydot = [y(2); -wsq*sin(y(1))];
pend_cl
functionxdot = pend_cl(t1,x) %for linear
wsq = (12*9.81*L)/(4*L^.2)+(d.^2)-(12*L*L1)+(12*L1.^2);
xdot = [x(2); -wsq*x(1)];
pend_solve
clear all;
clc;
clf;
tic;
tspan = 0:0.01:4.5;
a=pi/2;
b=0;
L=25;
L1=10;
d=5;
x0 = [a; b]; %a is initial disp,
%b is initial velocity
[t1,x] = ode45(@pend_cl,tspan,x0);
X1 = x(:,1); %X1 is angular disp for linear
X2 = x(:,2); %X2 is angular accln for linear
y0 = [a ; b];
[t2,y] = ode45(@pend_cn,tspan,y0);
Y1 = y(:,1); %Y1 is angular disp for non linear
Y2 = y(:,2); %Y2is angular acclnfor non linear
figure(1);
subplot(2,2,1);
plot(t1,X1);
xlabel('Time (s)');
ylabel('Displacement (rad)');
hold on;
grid on;
plot(t2,Y1);
% legend('Linear','Non Linear');
subplot(2,2,2);
% figure(2);
plot(t1,X2);
xlabel('Time (s)');
ylabel('Velocity (rad/s)');
hold on;
grid on;
plot(t2,Y2);
subplot(2,2,3);
plot(X1,X2);
hold on;
plot(Y1,Y2);
xlabel('Displacement (rad)');
ylabel('Velocity (rad/s)');
grid on;
toc;
  1 commentaire
Rik
Rik le 7 Nov 2020
I'm not quite sure how to edit your question for you. Please use the tools explained on this page to make your question more readable.

Connectez-vous pour commenter.

Réponses (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by