{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Pendulum - %Assign time step(delta t deltat=.01%Assign...

This preview shows page 1. Sign up to view the full content.

%Bryan Choquette %ME 082 %Week 4 Assignment clc clear all %Assign values to the constants g=9.81; L=1; %Create initial position of the rod, bob, and hinge data=([0 0;0 -L]); figure(1) axis([-2 2 -2 2]); rod = line('xdata',data(1,:),'ydata',data(2,:)); hinge = line(0,0,'marker','o'); bob = line('xdata',data(1,2),'ydata',data(2,2),'marker','o','markersize',15); %Assign initial conditions theta0=pi/4; thetadot0=0;%release from rest theta(1)=theta0; thetadot(1)=thetadot0; t0=0; t(1)=t0; k=1;
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %Assign time step (delta t) deltat=.01; %Assign final time tfinal=25; %Create the loop and apply changes to the image while t<tfinal pause(.08) t(k+1)=t(k)+deltat; theta(k+1)=theta(k)+thetadot(k).*deltat; thetadot(k+1)=thetadot(k)-(((g/L).*sin(theta(k)).*deltat)); r=[cos(theta(k+1)) -sin(theta(k+1));sin(theta(k+1)) cos(theta(k+1))]; x=r*data; set(rod,'xdata',x(1,:),'ydata',x(2,:)); set(bob,'xdata',x(1,2),'ydata',x(2,2)); drawnow k=k+1; end...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern