Azzera filtri
Azzera filtri

how to read a function handle parameter when i use ode23

2 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Torsten
Torsten il 27 Giu 2016
x from above is just a formal paramter. The solution is returned in the y-vector.
Best wishes
Torsten.
  3 Commenti
Muna Shehan
Muna Shehan il 27 Giu 2016
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 il 28 Giu 2016
I think it's easier if you explain the underlying problem in more detail ...
Best wishes
Torsten.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by