File: bvpfcn.m Line: 1 Column: 23 Invalid use of operator.
1 次查看(过去 30 天)
显示 更早的评论
function dydx = bvp4c(@ode,@bc,solinit); % equation to solve
plot(r.x,r.y(1,:),'--o');
title('chlorine decay')
xlabel('pipe length(m)');
ylabel('Concentration (mg/L)');
function dydx = ode(x,y)
D=0.1; % m2/s
U=1; % m/s
K = 1*10^-6; % 1/s
dydx = [y(2);(U*y(2)+k*y(1))/D];
end
function res = bcfcn(ya,yb) %boundary conditions
res = [ya(1)-3 yb(1)-2];
end
function g = guess (x) % initial guess for y and y'
guess = [2;1];
xmesh = linspace(0,1,5);
solinit = bvpinit(xmesh,guess);
Hi, I'm doing a project on Formation of Disinfection Byproducts during Water Treatment, to solve this problem with the following Eulers method . I have wrriten the code but I need to plot thr absolute percent error in the concentration A at each time step. I have tried searching in MATLAB Answers pertaining to my topics of study, but to no avail. The MATLAB code and the error message are shown below.
The reaction rate is typically assumed to be first order in the concentration of chlorine (A) and a NOM (B), yielding the following system of ODEs: 𝑑𝐴/𝑑𝑡 = −𝐾 ∗ 𝐴 ∗ 𝐵 𝑑𝐵/𝑑𝑡 = (𝑏/𝑎) ∗ (𝑑𝐴/𝑑𝑡) = −𝑌𝐵 ∗ (𝐾 ∗ 𝐴 ∗ 𝐵) 𝑑𝑃/𝑑𝑡 = −(𝑝/𝑎) ∗ (𝑑𝐴/𝑑𝑡) = 𝑌𝑃 ∗ (𝐾 ∗ 𝐴 ∗ 𝐵) where, K is the rection rate constant (L/mg/sec). The analytical solution for the concentration of A can be described as: 𝐴(𝑡) = 𝐴0 − 𝐵0/𝑌𝐵 1 − 𝐵0 𝑌𝐵𝐴0 exp [− ( 𝑌𝐵𝐴0 𝐵0 − 1) ∗ 𝐾 ∗ 𝐵0 ∗ 𝑡] where, A0 and B0 are the initial concentrations of Chlorine and NOM (mg/L).
The parameters are 𝑌𝐵 = 1, 𝑌𝑃 = 0.15, 𝐴0 = 1 mg/L, 𝐵0 = 3 mg/L, 𝑃0 = 0, 𝐾 = 5E − 5.
I have also attached the code/data for your convenience. I appreciate your help with troubleshooting the problem.Thanks for considering my request.
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!