hw08_p06b - % File name: hw08_p06b.m % RK4 and AB4-AM4 for...

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

View Full Document Right Arrow Icon
% File name: hw08_p06b.m % RK4 and AB4-AM4 for a linear system % Written by Jason Kenny and modified by Sangheon Lee clc clear c xmin = input('x_min: '); xmax = input('x_max: '); x(1) = input('x1: '); Y1(1) = input('Y1_1: '); Y2(1) = input('Y2_1: '); Y3(1) = input('y3_1: '); Y h = input('h: '); h % int_1 is for making table using 'mod' operator if h == 1/4 int_1 = 1; elseif h == 1/8 int_1 = 2; elseif h == 1/16 int_1 = 4; else int_1 = 1; end e x=xmin:h:xmax; x %We need to get a total of 4 starting values for AB4-AM4, so we use RK4 to %get the next 3 after the initial (given) value. Recycling the function %from part (a): for i=2:4 [Y1(i), Y2(i), Y3(i)] = hw08_p06RK4(h,x(i-1),Y1(i-1),Y2(i-1),Y3(i-1)); end e %Get fprime values for the points already calculated: for i=1:4 fprime1(i) = Y2(i); fprime2(i) = Y3(i); fprime3(i) = -4.0*Y3(i) - 5.0*Y2(i) - 2.0*Y1(i) + 2.0*x(i)^2 + 10.0*x(i) + 8.0; end e for i=5:length(x) %AB4 predictor. We'll store these predictions in the Y arrays, then %overwrite them with the corrected values later:
Background image of page 1

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

View Full DocumentRight Arrow Icon
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 02/22/2010 for the course CHE 348 taught by Professor Chelikowsky during the Spring '08 term at University of Texas.

Page1 / 2

hw08_p06b - % File name: hw08_p06b.m % RK4 and AB4-AM4 for...

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