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

1 回表示 (過去 30 日間)
Naveen Krish
Naveen Krish 2022 年 3 月 18 日
編集済み: Torsten 2022 年 3 月 18 日
function dydx = ode(y, x)
D = 0.1; % m2/s
U = 1; % m/s
K = 1e-6; % 1/s
dydx = [y(2)*
(U * y(2) + K * y(1)) / D]; % EDITED, parentheses added
end
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*e-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);
Question
I need to solve this ODE D*d^2C/dx^2 - U*dC/dx - KC = 0 using Matlab's BVP4C function. I need to plot C vs x.
my parameters are 𝐷 = 0.1 m2 /s, 𝑈 = 1 m/s, 𝐾 = 1𝐸 − 6 s -1 , 𝐶𝑖𝑛 = 3 mg/L, 𝐶𝑜𝑢𝑡 = 2 mg/L, 𝐿 = 1.0 m

回答 (0 件)

カテゴリ

Help Center および File ExchangeSignal Processing についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by