How to set diffrent initial conditions as a vector.

3 次查看(过去 30 天)
I want define the initial condtions as vector that contains diffrent temperature value for each node.
global rho Cp k t Tair h1 h2
rho = 1;
Cp = 4.187;
k = 0.59803;
L = 1;
x = linspace(0,L,5);
endt = 0.5*3600;
t = linspace(0,endt,1+endt/60);
m = 0;
Tair = 0;
h1 =10;
h2 = 30;
sol = pdepe(m,@heatpde,@heatic,@heatbc,x,t);
figure
plot(t/60,sol,'LineWidth',1.5)
legend('Node 1','Node 2','Node 3','Node 4','Node 5')
function [c,f,s] = heatpde(x,t,u,dudx)
global rho Cp k
c = rho*Cp*1000;
f = k*dudx;
s = 0;
end
function u0 = heatic(x)
u0 = 20;
end
function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t)
global Tair h1 h2
pl = -(h1)*(ul-Tair);
ql = 1;
pr = (h2)*(ur-Tair);
qr = 1;
end

采纳的回答

Torsten
Torsten 2023-6-6
编辑:Torsten 2023-6-6
I already showed you how to do that.
If xvec and Tvec are your given vectors of grid points and associated temperatures, set
heatic = @(x)interp1(xvec,Tvec,x);
sol = pdepe(m,@heatpde,heatic,@heatbc,x,t);

更多回答(0 个)

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by