hw09_p04 - clc clear h = input('h: '); xstart =...

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

View Full Document Right Arrow Icon
clc clear h = input('h: '); xstart = input('x_min: '); xend = input('x_max: '); ystart = input('y at x_min: '); yend = input('y at x_max: '); tolerance = input('Tolerance: '); % int_1 is for making table using 'mod' operator if h == 0.2 int_1 = 1; elseif h == 0.1 int_1 = 2; elseif h == 0.05 int_1 = 4; elseif h == 0.025 int_1 = 8; elseif h == 0.0125 int_1 = 16; else int_1 = 1; end e n = 1; n p_initial = input('1 st initial guess: '); p x=xstart:h:xend; x Y1(1,n) = ystart; Y2(1,n) = p_initial; Y for i=2:length(x) % [Y1(i,n), Y2(i,n)] = hw09_p04Trap(h,x(i-1),Y1(i-1,n),Y2(i-1,n)); % P-C [Y1(i,n), Y2(i,n)] = hw09_p04RK4(h,x(i-1),Y1(i-1,n),Y2(i-1,n)); % RK4 end e diff(n) = Y1(length(x),n) - yend; d p_initial = input('2 nd initial guess: '); p n=n+1; n Y1(1,n) = ystart; Y2(1,n) = p_initial; Y for i=2:length(x) % [Y1(i,n), Y2(i,n)] = hw09_p04Trap(h,x(i-1),Y1(i-1,n),Y2(i-1,n)); % P-C [Y1(i,n), Y2(i,n)] = hw09_p04RK4(h,x(i-1),Y1(i-1,n),Y2(i-1,n)); % RK4 end e diff(n) = Y1(length(x),n) - yend; d while ( abs( Y2(1,n) - Y2(1,n-1) ) > tolerance )
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.

Page1 / 2

hw09_p04 - clc clear h = input('h: '); xstart =...

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