Defining function file of ODE function

1 回表示 (過去 30 日間)
Carey n'eville
Carey n'eville 2020 年 11 月 23 日
コメント済み: Carey n'eville 2020 年 11 月 23 日
%We have initial concentration C(0)=5, but I didn't understand how I use this value and also my code does'nt work.
function dCdt=Conc(C,t)
global t;
global C;
k1=0.7;
t=0:1:6;
Vo=1;
Q=Vo;
Cin=200;
dCdt=-(k1+(t/(Vo+Q*t)))*C+((Q*Cin)/(Vo+Q*t));
end
%I get this error, Could you help to me, please:
%Error using /
%Matrix dimensions must agree.
%Error in Conc (line 10)
% dCdt=-(k1+(t/(Vo+Q*t)))*C+mrdivide((Q*Cin),(Vo+Q*t));

採用された回答

Stephan
Stephan 2020 年 11 月 23 日
編集済み: Stephan 2020 年 11 月 23 日
C0 = 5;
tspan = [0 10];
[t,C] = ode45(@Conc,tspan,C0);
plot(t,C)
function dCdt=Conc(t,C)
k1=0.7;
Vo=1;
Q=Vo;
Cin=200;
dCdt=-(k1+(t./(Vo+Q.*t)))*C+((Q*Cin)/(Vo+Q.*t));
end
  1 件のコメント
Carey n'eville
Carey n'eville 2020 年 11 月 23 日
Wow thank you so much!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by