File: bvpfcn.m Line: 1 Column: 23 Invalid use of operator.
1 view (last 30 days)
Show older comments
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/935809/image.png)
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 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!