how to read a function handle parameter when i use ode23

2 次查看(过去 30 天)
Hi all; I use ode23 to solve the ordinary differential equations in the form.
[~,y] = ode23(@(t,x)f(t,x,0, kc, @(t)lookup_u(zdot,t)), [0 2], x00,opt);
My quation is: can I read the value x after ode23 is solved to use these values in a different function? Regards

回答(1 个)

Torsten
Torsten 2016-6-27
x from above is just a formal paramter. The solution is returned in the y-vector.
Best wishes
Torsten.
  3 个评论
Muna Shehan
Muna Shehan 2016-6-27
I reviewed MathWorks Support Team question and their answer about " how to pass out extra parameters using ODE23 or ODE45 from the MATLAB ODE suite?".
Their answer is clear, and I have some thing similiar where I intent to read and save the return extra parameters, but when I try to fit it to my code I do not know how to deal with function handles for anonymous function. In my case I need to store x when the ode23 is solved. while in Mathworks Support Team their function is
function [dydx k] = myode(x, y)
k = x.^2 + y.^2;
dydx = x + k.*y;
Then, " k" can be obtained via the command
[dydx k] = myode(X, Y);
while in my case the function handles for anonymous function is
function [dx,x] = f(t, x, ~, kc,z)
param.ms = 325;
param.mus = 65;
param.kus = 232.5e3;
u=0;
J = jacobian(t, kc, param);
A = J(1:4,1:4);
B = J(1:4, 5);
b_ramp = [-1; param.ct/param.mus; 0; 0];
if ~isempty(z)
dx= A* x + B * u + b_ramp * z(t);
else
dx = A*x + B*u ;
end
end
My qestion is how I can obtaine x similiar to Math Work Support answer way? Regards
Torsten
Torsten 2016-6-28
I think it's easier if you explain the underlying problem in more detail ...
Best wishes
Torsten.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by