Homework 9 - 34) The program mynonlinheat.m has been...

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

View Full Document Right Arrow Icon
34) The program mynonlinheat.m has been modified to have the boundary conditions of u(0)=0 and u(L)=10. The modified program produces graphs of the initial guess of the program as well as the initial guess and 400 iterations of the for loop. Modified code of mynonlinheat.m % mynonlinheat % Math 344 % Homework Problem 34 % Writen by Astrom and Elbert % L = 4; % Rod length (L) n = 400; % number of intervals (n) h = L/n; % Define h hh = h^2/3; % Define h u0 = 0; % u(0) boundary condition value uL = 10; % u(L) boundary condition value ub = .5; % Background temperature ub4 = ub^4; % Define ub to the fourth x = 0:h:L+h; % Vector of x values g = sin(pi*x/4); % Temperature function u = zeros(1,n+2); % Initial guess steps = 400; % number of times to run loop u(1) = u0; % Set 1st boundary condition u(n+2) = uL; % Set 2nd boundary condition figure % Individual graph plot(x,u) % Plot initial guess figure % Individual graph plot (x,u) % Plot initial guess hold on for j = 1:steps % Loop u(2:n+1) = (u(3:n+2)+u(2:n+1)+u(1:n))/3 + hh*(-u(2:n+1).^4+ub4-g(2:n+1)); plot(x,u) % Plot each time end plot(x,u) % Plot value after steps value Graphs Figure 34a – Graph of initial guess
Background image of page 1

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

View Full DocumentRight Arrow Icon
Figure 34a – Graph after 500 steps **************************************************************************** 35) This program has been modified to produce both graphs with one run of the program. After changing d from .1 to .01 it was seen that the final temperature at r = 0 changed from 10.06 to 10.5264. We can see that d = 0.10 converges after around 7 iterations were as d = 0.01 take many more iterations to converge. This is shown in the graphs below. The output of the program is displayed. The values at the beginning and the end are the only parts of the output shown to save paper. Code
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/15/2011 for the course MATH 345 taught by Professor Staff during the Spring '08 term at Ohio State.

Page1 / 8

Homework 9 - 34) The program mynonlinheat.m has been...

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

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