No BSD License  

Highlights from
Advanced Mathematics and Mechanics Applications Using MATLAB, 3rd Edition

image thumbnail

Advanced Mathematics and Mechanics Applications Using MATLAB, 3rd Edition



14 Oct 2002 (Updated )

Companion Software (amamhlib)

function slabheat      
% Example: slabheat
% ~~~~~~~~~~~~~~~~~
% This program computes the temperature 
% variation in a one-dimensional slab with 
% the left end insulated and the right end 
% given a temperature variation sin(w*t).
% User m functions required:  heat

surf(x1,t1,u1); axis([0 1 0 2 -2 2]);
title('Temperature Variation in a Slab');
xlabel('x axis'); ylabel('time'); 
zlabel('temperature'); view([45,30]), shg
colormap(gray), brighten(.7)
disp(' '), disp('Press [Enter] to continue')
print -deps tempsurf

plot(t2,u2(:,1),'--k',t2,u2(:,2),':.k', ...
title(['Temperature History at Ends' ...
       ' and Middle']);
xlabel('dimensionless time');
ylabel('dimensionless temperature');
text1='Left End'; text2='Middle';
text3='Right End';
legend(text1,text2,text3,3); shg
print -deps templot 
disp(' '), disp('All Done');


function [u,t,x]= ...
% This function evaluates transient heat 
% conduction in a slab which has the left end 
% (x=0) insulated and has the right end (x=1) 
% subjected to a temperature variation 
% sin(w*t). The initial temperature of the slab
% is zero.
% w          - frequency of the right side
%              temperature variation
% tmin,tmax  - time limits for solution
% nt         - number of uniformly spaced
%              time values used
% xmin,xmax  - position limits for solution.
%              Values should lie between zero
%              and one.
% nx         - number of equidistant x values
% nsum       - number of terms used in the 
%              series solution
% u          - matrix of temperature values.
%              Time varies from row to row.
%              x varies from column to column.
% t,x        - vectors of time and x values
% User m functions called:  none.

W=sqrt(-i*w); ln=pi*((1:nsum)-1/2); 
v1=ln+W; v2=ln-W;
u=imag(cos(W*x)*exp(i*w*t)/cos(W))+ ...
  (a(ones(nx,1),:).*cos(x*ln))* ...
u=u'; t=t(:);

Contact us