pdepe help!! incorrect answer
3 views (last 30 days)
Show older comments
Hi guys,
Script is working, however I don't get the correct result for the XvsC graph, what is the problam, how can I solve that, is there any other way to solve this?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/257537/image.png)
clc
clear
%% defining the mash points
x = linspace(0,15000,10); %defining distance from 0 to 15000m which is divaded in to 10
t = linspace(0, 30, 30); %defining time from 0 to 30th day which is divided in to 30
m = 0;
sol = pdepe(m, @pde,@pdeic,@pdebc,x,t);
%% ploting for the x(m) vs C(30, x)(mg/L) for t = 30 day
sol(30,:);
plot(x, sol(30,:))
xlabel('Distance (m)')
ylabel('Concentration (mg/L)')
title('x vs C for t = 30 day')
%% ploting for the t(day) vs C(t, 5)(mg/L) for x = 7500 m
sol(:, 5);
plot(t, sol(:, 5))
xlabel('Time (days)')
ylabel('Concentration (mg/L)')
title('t vs C for x = 50 m')
%% main function that represent our governing equation
function [c, f, s] = pde(x, t, C, dCdx)
c = 1;
f = -49680*C;
s = -(0.24+0.45/5)*C;
end
%% defining the initial condition
function u0 = pdeic(x)
u0 = 25;
end
%% defining the boundry condition
function [pl,ql,pr,qr] = pdebc(xl,ul,xr,ur,t)
pl = ul - 13.75;
ql = 0;
pr = ur - 0.05;
qr = 0;
end
4 Comments
Bill Greene
on 29 Dec 2019
The problem you have modeled makes little sense to me. You have a flow velocity of 49680 m/day and you are looking for a solution after 30 days yet you have modelled a domain of just 15000 m. What were you expecting the solution to look like in this domain after 30 days?
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!