Can I store ode23 the function handle parameters?
1 次查看(过去 30 天)
显示 更早的评论
Hi all; I use ode23 to solve the ordinary differential equations
[t02,y] = ode23(@(t,x)f(t,x,F,kc, @(t)lookup_u(zdot,t)), [0 2], x00,opt);
As the function handle ( @(t,x)f(t,x,F,kc, @(t)lookup_u(zdot,t)) depends on another function handle ( @(t)lookup_u(zdot,t)) which is
function u = lookup_u(tu, t)
i = find(tu.t <= t, 1, 'last');
[m,n] = size(tu.u);
if (m==1) || (n==1)
if i<length(tu.t)
u = (tu.u(i)*(tu.t(i+1) -t) + tu.u(i+1)*(t-tu.t(i)))/(tu.t(i+1)-tu.t(i));
else
u = tu.u(i);
end
else
if i < length(tu.t)
u = (tu.u(:,i)*(tu.t(i+1) -t) + ...
tu.u(:,i+1)*(t-tu.t(i)))/(tu.t(i+1)-tu.t(i));
else
u = tu.u(:,i);
end
end
end
My question: Is there any way to save t and u values in a vectors as they change at every integration step. Regards
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!