Solving differential equation using ode45
2 次查看(过去 30 天)
显示 更早的评论
looking to solve this problem using the function ode45
6 个评论
回答(1 个)
Torsten
2023-5-9
移动:Torsten
2023-5-9
Here is the solution of your problem for reference:
x = linspace(0,1,25);
t = linspace(0,2.5,25);
m = 0;
sol = pdepe(m,@heatcyl,@heatic,@heatbc,x,t);
u = sol(:,:,1);
plot(x,[u(5,:);u(10,:);u(20,:);u(25,:)])
function [c,f,s] = heatcyl(x,t,u,dudx)
u = @(t) 1;
h = @(x) 0.1*(x >=0.4 & x <= 0.6);
c = 1;
f = dudx;
s = h(x)*u(t);
end
%----------------------------------------------
function u0 = heatic(x)
u0 = 0;
end
%----------------------------------------------
function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t)
pl = ul; %ignored by solver since m=1
ql = 0; %ignored by solver since m=1
pr = 0;
qr = 1;
end
%----------------------------------------------
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!