%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Compute position and velocity of coupled masses with f external %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% s10 = 0.2; % initial position s1_dot0 = -1; % initial velocity s20 = 0.4; % initial position s2_dot0 = -1; % initial velocity tspan = [0 10]; % time boundaries x0 = [s10;s1_dot0;s20;s2_dot0]; global w02 f_input k l w02 = 5; l=1; f_input = inline('0'); %no external forcing. [t,x] = ode45('f5',tspan, x0); x1 = x(:,1); x2 = x(:,2); x3 = x(:,3); x4 = x(:,4); subplot(3,1,1) plot(t,x1,t,x3); xlabel('time in s'); ylabel('positions (m)'); title('simple damped pendulum with forcing'); subplot(3,1,2) plot(t,x2,t,x4); xlabel('time in s'); ylabel('velocities (m/s)'); subplot(3,1,3) plot(t,f_input(t)); xlabel('time in s'); ylabel('input');