how to read a function handle parameter when i use ode23

조회 수: 2 (최근 30일)
Muna Shehan
Muna Shehan 2016년 6월 27일
댓글: Torsten 2016년 6월 28일
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