文档介绍:SampleMATLABcodes1.%NewtonCoolingLawclear;closeall;clc;h=1;T(1)=10;%T(0)error=1;TOL=1e-6;k=0;dt=1/10;whileerror>TOL,k=k+1;T(k+1)=h*(1-T(k))*dt+T(k);error=abs(T(k+1)-T(k));endt=linspace(0,dt*(k+1),k+1);plot(t,T),holdon,plot(t,1,'r-.')xlabel('Time'),ylabel('Temperature'),title(['T_0=',num2str(T(1)),',T_\infty=1']),legend('CoolingTrend','SteadyState')2.%BoltzmanCoolingLawclear;closeall;clc;h=1;T(1)=10;%T(0)error=1;TOL=1e-6;k=0;dt=1/10000;whileerror>TOL,k=k+1;T(k+1)=h*(1-(T(k))^4)*dt+T(k);error=abs(T(k+1)-T(k));endt=linspace(0,dt*(k+1),k+1);plot(t,T),holdon,plot(t,1,'r-.')xlabel('Time'),ylabel('Temperature'),title(['T_0=',num2str(T(1)),',T_\infty=1']),legend('CoolingTrend','SteadyState')3.%FourierHeatconductionclear;closeall;clc;h=1;n=11;T=ones(n,1);Told=T;T(1)=1;%LeftboundaryT(n)=10;%Rightboundaryx=linspace(0,1,n);dx=x(2)-x(1);dt=dx^2/3;%cflconditionerror=1;TOL=1e-6;k=0;whileerror>TOL,Told=T;k=k+1;fori=2:n-1T(i)=dt*(Told(i+1)-2*Told(i)+Told(i-1))/dx^2+Told(i);enderror=max(abs(T-Told));ifmod(k,5)==0,out(k,:)=T;endendplot(x,out)xlabel('x'),ylabel('Temperature'),title(['FourierHeatConduction']),%legend('CoolingTrend','SteadyState')%;closeall;=10;%gridhasn-2interiorpointsperdimension(overlapping)x=linspace(0,1,n);dx=x(2)-x(1);y=x;dy=dx;TOL=1e-6;T=zeros(n);T(1,1:n)=10;%TOPT(n,1:n)=1;%BOTTOMT(1:n,1)=1;%LEFTT(1:n,n)=1;%RIGHTdt=dx^2/4;error=1;k=0;whilee