How to set diffrent initial conditions as a vector.

2 vues (au cours des 30 derniers jours)
Zakaria OUAOUJA
Zakaria OUAOUJA le 6 Juin 2023
Modifié(e) : Torsten le 6 Juin 2023
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

Réponse acceptée

Torsten
Torsten le 6 Juin 2023
Modifié(e) : Torsten le 6 Juin 2023
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);

Plus de réponses (0)

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by