% Conduction of heat in a semiinfinite slab with the x=0 surface varying % sinusiodally in time with amplitude T0 and radian frequency omega. % The diffusivity is kappa=k/(rho*c) % This m-file was written at the University of Wyoming in the Electrical % and Computer Engineering Department and is to be distributed without % cost. clear all set(0,'DefaultAxesFontSize',12); set(0,'DefaultTextFontSize',12); figure(1);clf figure(2);clf figure(3);clf figure(4);clf omegat=linspace(0,20,201); betax=linspace(0,10,101); Tdata=[]; for i=1:201 T=exp(-betax).*sin(omegat(1,i)*ones(1,101)-betax); Tdata=[Tdata;T]; end figure(1);% Plot T(x,t) vs x for various t xlabel('Dimensionless Distance, \betax') hold on ylabel('Dimensionless Temperature, T(x,t)/T_0') for k=1:4:49 plot(betax,Tdata(k,:),'k') hold on axis([0 10 -1.2 1.2]); hold on %pause end text(6,-.8,'\beta = sqrt(\omega/2*\kappa)') text(1.2, -.3,'\omegat = 0') text(6,-1 ,'\Delta(\omegat) = 0.4') set(gca,'Box','on') text(6,.8,'Press Enter to Continue') pause figure(2)%Plot T(x,t) vs t for various x for j=1:4:101 plot(omegat, Tdata(:,j)); hold on axis([0 10 -1.2 1.2]); hold on end text(6,-1,'\Delta(\betax) = 0.4') text(2.5,.8,'\betax = 0') xlabel('Dimensionless Time, \omegat') ylabel('Dimensionless Temperature, T(x,t)/T_0') text(6,-.8,'\beta = sqrt(\omega/2*\kappa)') text(12,.8,'Press Enter to Continue') pause figure(3)%now do animation axis([0 10 -1.2 1.2]) hold on box on xlabel('Dimensionless Distance, \betax') hold on ylabel('Dimensionless Temperature, T(x,t)/T_0') hold on L=plot(betax, Tdata(1,:),'k','EraseMode','xor'); hold on texthandl=text(6, .8,'Press Enter to Animate'); pause set(texthandl,'String',' '); for i=1:201 set(L,'Ydata',Tdata(i,:)) pause(.04) end hold on set(texthandl,'String','Press Enter to Continue'); pause figure(4)%3-D Plot of T(x,t) vs x and t Tdata2=[]; for i=1:2:201 Tdata2=[Tdata2;Tdata(i,:)]; end axis([0 20 0 10 -1.2 1.2]) omegat2=linspace(1,20,101); [X,Y]=meshgrid(omegat2,betax); mesh(X,Y,Tdata2') colormap([0 0 0])%cool) text(0, 1, -2.,'Time,\omegat','Rotation',-30) text(20, 4, -1.7,'Distance, \betax','Rotation',13) zlabel('Dimensionless Temperature, T(x,t)/T_0') text(0,6,.7,'Press Enter to Continue') view(60,30) axis([0 20 0 10 -1.2 1.2])