File: bvpfcn.m Line: 1 Column: 23 Invalid use of operator.

1 visualizzazione (ultimi 30 giorni)
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.

Risposte (0)

Categorie

Scopri di piรน su Mathematics in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by