Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Note: The following Matlab functions are mentioned/needed in problem. Math 128A:

ID: 3865453 • Letter: N

Question

Note: The following Matlab functions are mentioned/needed in problem.

Math 128A: Homework 7 Due: August 2 1. In this problem, we will study the evolution of a double pendulum. The state of the configuration at any time t is given by the angles 1(t) and 64(t), see figure below. The MATLAB utility pendplot.m can be used to visualize the double pendulum in Figure 1: The double pendulum any configuration. Here is an example of how to use it, to animate the motion 1(t)- 2sin(t).@g(t) = sin(2t): for t 0 : 0.01 : 10. pendplot(2 * 81n(t), 81n(2 * t)); end This motion was of course just made up and does not correspond to a true, physical motion. We will now solve for the actual evolution of the pendulum for various initial conditions. (a) Assuming that the lengths of the bars are1, the masses at the end of the bars are 1, and that the constant of gravity is 1, the equations of motion for the double pendulum can be written as -3sin(6, ) _ sin(91-2%) _ 2 sin(91-82) . (e? + cos(81-82)) 3- cos(20-20) gu) 3-cos(20-202) Rewrite (1) into a system of 1st order equations by introducing the angular ve- locities = and w2 = 0, The current state of the pendulum can then be described by the vector z = (o,.02.11.12), and the 1st order system can be writ- ten as z'(t) = f(z). Write a MATLAB function fpend.n of the form function zprine fpend,z)

Explanation / Answer

function double_pendulum(ivp, duration, fps, movie) % DOUBLE_PENDULUM Animates the double pendulum's (mostly) chaotic behavior. % % % % parameters: % % ivp=[phi1; dtphi1; phi2; dtphi2; g; m1; m2; l1; l2] % % Initial value problem. phi1 and dtphi1 are % the initial angle and anglular velocity. g % is gravity, m1 and l1 mass and rod length. % For an explaining picture, see % documentation file in same folder. % % duration The time interval on which the ode is % solved spans from 0 to duration (in sec). % % fps Frames Per Second. The framerate is % relevant both for normal (realtime) % animation and movie recording. % % movie If false, a normal realtime animation of % the motion of the double pendulum (the % framerate being fps) is shown. % If true, a movie (.avi) is recorded. The % filename is 'doublePendulumAnimation.avi' % and the folder into which it is saved is % the current working directory. % % This function calls double_pendulum_ODE and is, in turn, called by % double_pendulum_init. % % Example call: >> double_pendulum([pi;0;pi;5;9.81;1;1;2;1],100,10,false) % Or, simply call >> double_pendulum_init % % --------------------------------------------------------------------- clear All; clf; nframes=duration*fps; sol=ode45(@double_pendulum_ODE,[0 duration], ivp); t = linspace(0,duration,nframes); y=deval(sol,t); phi1=y(1,:)'; dtphi1=y(2,:)'; phi2=y(3,:)'; dtphi2=y(4,:)'; l1=ivp(8); l2=ivp(9); % phi1=x(:,1); dtphi1=x(:,2); % phi2=x(:,3); dtphi2=x(:,4); % l1=ivp(8); l2=ivp(9); h=plot(0,0,'MarkerSize',30,'Marker','.','LineWidth',2); range=1.1*(l1+l2); axis([-range range -range range]); axis square; set(gca,'nextplot','replacechildren'); for i=1:length(phi1)-1 if (ishandle(h)==1) Xcoord=[0,l1*sin(phi1(i)),l1*sin(phi1(i))+l2*sin(phi2(i))]; Ycoord=[0,-l1*cos(phi1(i)),-l1*cos(phi1(i))-l2*cos(phi2(i))]; set(h,'XData',Xcoord,'YData',Ycoord); drawnow; F(i) = getframe; if movie==false pause(t(i+1)-t(i)); end end end if movie==true movie2avi(F,'doublePendulumAnimation.avi','compression','Cinepak','fps',fps) end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote