Cheat sheet - Exam 1

Cheat sheet - Exam 1 - Loops: Euler's RK2: for k1

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

View Full Document Right Arrow Icon
Loops: Euler’s RK2: for k1 (i,:)=h*de(t(i),Run1(i,:),K)'; k2(i,:)=h*de((t(i)+h/2),(Run1(i,:)+k1(i,:)/2),K)'; Run1(i+1,:)=Run1(i,:)+k2(i,:); End; Simpsons: ( 29 ( 29 1 2 3 4 5 3 2 1 ; ( ) 4 ( ) 2 ( ) 4 ( ) 2 ( ) 2 ( ) 4 ( ) ( ) h n n n S f P f x f x f x f x f x f x f x f x - - = + + + + + + + + L e venvectors=conc(2:2:(n-1)); oddvectors=conc(3:2:(n-1)); even=4*evenvectors; odd=2*oddvectors; Simpsons=(h/3)*(conc(1)+sum(even)+sum(odd)+conc(end)); Trapezoidal: ( 29 ( 29 ( 29 ( 29 ( 29 1 1 2 2 ; n h n i i T f P f x f x h f x - = = + + Trapezoidal=(h/2)*(conc(1)+conc(end))+h*((sum(conc)-conc(1)-conc(end))); Rectangular: ( 29 1 1 ( ; ) n i i R f P h f x - = = Rectangular=h*(sum(conc)-conc(end)); Matlab functions: Trapz: trapzfunc=trapz(time,conc); spline: xx=[0:.1:12]; yy=spline(time,conc, xx); plot(time,conc, 'o' , xx, yy, '-' ); ODE45: options =odeset( 'Reltol' , 1e-5, 'AbsTol' ,1e-5); [T1,x11]=ode45( 'dede' ,[0 20],Run1(1,:),options,K); [T2,x22]=ode45( 'dede' ,[0 20],Run2(1,:),options,K); Euler’s: x ( t + h ) = x ( t ) + h f ( x ( t ), t ) RK2: Implicit Euler’s: Function file:
Background image of page 1

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

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

This note was uploaded on 05/05/2008 for the course BME 210 taught by Professor D'argenio during the Spring '07 term at USC.

Page1 / 2

Cheat sheet - Exam 1 - Loops: Euler's RK2: for k1

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

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