linsysfinal - oo=ones(size(t)); ss=ones(size(t));...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Amber Mueller i) function [T]=ploti t=0:.1:5; T = t.*(one(t,0)-one(t,2)) plot (t,T, '.' ) function ss=one(t,aj) jj=find(t<aj); zz=zeros(size(t)); oo=ones(size(t)); ss=ones(size(t)); ss(jj)=zz(jj); return function [t,theta,thetaa]=parti clear all close all clc t0=0; tf=5; theta_init=[10*pi/180 0]; % approximate solution options = odeset( 'AbsTol' ,1e-8, 'RelTol' ,1e-8); [t,theta]=ode45(@eom,[t0 tf],theta_init,options); % analytic solution
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Amber Mueller thetat = (0.011+0.033.*t+2.*exp(-5.*t).*(.00529.*cos(2.19.*t) +.00367.*sin(2.19.*t))+0.011+0.033.*(t-2)+2.*exp(-5.*(t- 2)).*(.00529.*cos(2.19.*(t-2))+.00367.*sin(2.19.*(t-2)))+.067+2.*exp(- 5.*(t-2)).*(-.033*cos(2.19.*(t-2))-.0766.*sin(t-2))+.8*exp(- 5.*t).*sin(2.19.*t)+2*exp(-5.*t).*(-2.19/25.1.*cos(2.19.*t) +5/25.1.*sin(2.19.*t))).*one(t,0); % compare approximate vs. analytic solutions plot(t,thetat, 'g-' ,t,theta(:,1), 'r--' ) xlabel( 'time (s)' ) ylabel( 'theta(t)' ); legend( 'Analytic' , 'Numeric' ); title( 'parti' ) function ss=one(t,aj) jj=find(t<aj); zz=zeros(size(t));
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: oo=ones(size(t)); ss=ones(size(t)); ss(jj)=zz(jj); return % EOM file function [thetadot]=eom(t,theta) thetadot = zeros(2,1); T = t.*(one(t,0)-one(t,2)); thetadot(1)=theta(2); thetadot(2)=T-10*theta(2)-29.81*theta(1); return ; Amber Mueller k) function [t,x]=finalk for r=1:5 x0=[r;0]; t0=0; tf=20; options=odeset( 'AbsTol' ,1e-8, 'RelTol' ,1e-8); [t1,x]=ode45(@eom1,[t0 tf],x0,options); [t2,theta]=ode45(@eom2,[t0 tf],x0,options); figure(r) plot(t1,x(:,1), 'g-' ,t2,theta(:,1), 'r--' ) legend( 'Non-Linear' , 'Linear' ); end function xdot=eom1(t,x) xdot=zeros(2,1); xdot(1)=x(2); xdot(2)=-(10*x(2)+20*x(1)+9.81*sin(x(1))+.001885*x(2)^2); return function [thetadot]=eom2(t,theta) thetadot = zeros(2,1); thetadot(1)=theta(2); thetadot(2)=-10*theta(2)-29.81*theta(1); return ; deltheta(0)=1 deltheta(0)= 2 Amber Mueller deltheta(0)=3 Amber Mueller deltheta(0)= 4 Amber Mueller deltheta(0)=5 Amber Mueller...
View Full Document

This note was uploaded on 03/19/2008 for the course EM 319 taught by Professor Kennethm.liechti during the Spring '08 term at University of Texas at Austin.

Page1 / 7

linsysfinal - oo=ones(size(t)); ss=ones(size(t));...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online