assign10.sol - ASE 211 Homework 10 1. Write a matlab m-le...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: ASE 211 Homework 10 1. Write a matlab m-le which solves numerically the two-point boundary value convection-diusion problem cu (x) - u (x) = f (x), 0 < x < 1, with the boundary conditions method discussed in class with specied by the user. u(0) = u(1) = 0. Use the nite dierence n = 1/h. The coecient c 0 is a constant function U=twoptbvp(N,funf,c) h=1/n; A=zeros(n+1,n+1); b=zeros(n+1,1); for i=1:n+1 x(i)=(i-1)*h; end b(1)=0; b(n+1)=0; A(1,1)=1; A(n+1,n+1)=1; for i=2:n A(i,i)=2/h^2+c/h; b(i)=feval(funf,x(i)); end for i=2:n A(i,i-1)=-1/h^2-c/h; A(i,i+1)=-1/h^2; end U=A\b; plot(x,U) Figure 1: f (x) = 2, n = 20, c = 0 Test your code on the following cases: f (x) = 2, c = 0, n = 20 u(x) = x(1 - x)). and n = 40 (the true solution for this case is f (x) = 10x, c = 1, n = 20 and n = 40 n = 40 Hand in your plots and your f (x) = 10x, c = 10, n = 20 and For each case, plot the numerical solution. m-les. Label each plot. Figure 2: f (x) = 2, n = 40, c = 0 Figure 3: f (x) = 10x, n = 20, c = 1 Figure 4: f (x) = 10x, n = 40, c = 1 Figure 5: f (x) = 10x, n = 20, c = 10 Figure 6: f (x) = 10x, n = 40, c = 10 ...
View Full Document

Page1 / 7

assign10.sol - ASE 211 Homework 10 1. Write a matlab m-le...

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