HW7SolutionsF07

# HW7SolutionsF07 - clear all[t,v]=ode23'myfunction[0,10[1;2...

This preview shows pages 1–3. Sign up to view the full content.

1 ECE 220 Lab9 Solution Made by Rong Guo Problems 7.20 myfunction.m ------------------------------------------------------------- %Refer to matlab script7.3 on Page381. function yd=myfunction(t,v) A=[3 2;6 0]; b=[0;cos(2*pi*60*t)]; yd=A*v+b; return ----------------------------------------------------------------------- pro7x20.m -------------------------------------------------------------- clear all [t,v]=ode23( 'myfunction' ,[0,1],[-1/6;0]); plot(t,v(:,1), 'r' ); hold on %Plot v1 in red. plot(t,v(:,2), 'b' ); % Plot v2 in blue. grid on ---------------------------------------------------------------------- 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 -30 -25 -20 -15 -10 -5 0 v1 v2

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

View Full Document
2 Problems 7.21 myfunction.m ------------------------------------------------------------- function yd=myfunction(t,v) yd=zeros(2,1); yd(1)=v(2); yd(2)=-2*v(2)-v(1)+(cos(2*pi*t))^3; return ------------------------------------------------------------- pro7x21.m --------------------------------------------------------------------
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: clear all [t,v]=ode23( 'myfunction' ,[0,10],[1;2]); plot(t,v(:,1)); % v1 is the solution of differential equation. grid on xlabel( 't' ) ylabel( 'v(t)' ) ------------------------------------------------------------------------ 1 2 3 4 5 6 7 8 9 10-0.2 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 t v(t) 3 Problems 7.23 myfunction.m ---------------------------------------------------------- function yd=myfunction(t,v) yd=zeros(4,1); yd(1)=v(2); yd(2)=v(3); yd(3)=v(4); yd(4)=-3*v(3)-4*v(1)+2*sin(2*pi*t); return------------------------------------------------------------- pro7x23.m -------------------------------------------------------------------- clear all [t,v]=ode23( 'myfunction' ,[0,10],[0;1;2;0]); plot(t,v(:,1)); % v1 is the solution of differential equation. grid on--------------------------------------------------------------------= 1 2 3 4 5 6 7 8 9 10-100-80-60-40-20 20 40 60 80 t v(t)...
View Full Document

{[ snackBarMessage ]}

### Page1 / 3

HW7SolutionsF07 - clear all[t,v]=ode23'myfunction[0,10[1;2...

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

View Full Document
Ask a homework question - tutors are online