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!