vector and for-loop issues in ode solver
古いコメントを表示
Dear all, i am trying to solve a temperature-dependent kinetic expression in ode solver with concentration problem.
I'm not sure if making a loop for C in z direction(j) in ode is a correct way or not...
Any help or advice is greatly appreciated!!
Codes:
%F Interp to stepsize 5
x=0:5:l
F_fit=interp1(x_F,F,x)
function ddx= odefun(~, x) % x contains C
% x(1:n)=C
%%% How to make C alonz z with ceratin value ?
% Interp F
% C=rho./MW.*3.*(1-F_fit)
for j= 2:length(F_fit) %since C= x(1:input.n)
x(1:n,j)= rho./MW.*3.*(1-F_fit(j));
ddx(1)=MW.*(k0.*(rho).*exp(-Ea./(R.*x(n+1))).*x(1,j)...
-A(1).*(rho).*exp(-Ea./(R.*x(n+1))).*(C_0-x(1,j)));
ddx(2:n-1)=MW.*(k0.*(rho).*exp(-Ea./(R.*x(n+2:2*n-1))).*x(2:n-1,j)...
-A(2:n-1).*(rho).*exp(-Ea./(R.*x(n+2:2*n-1))).*(C_0-x(2:n-1,j)));
ddx(n)= MW.*(k0.*(rho).*exp(-Ea./(R.*x(2*n))).*x(n,j)...
-A(n).*(rho).*exp(-Ea./(R.*x(2*n))).*(C_0-x(n,j)));
end
ddx=ddx';
end
3 件のコメント
Star Strider
2022 年 11 月 30 日
I do not see any assignment to ‘f_eq’ in the posted code.
It needs to exist in the calling script workspace before it is passed as an argument.
uki71319
2022 年 11 月 30 日
Star Strider
2022 年 11 月 30 日
It appears that ‘f_eq’ needs to be an anonymous function.
It and all the arguments it needs will have to be passed to ‘odefun’.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!