How to apply time varying input with dlode45?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Emebet Gedlu
le 11 Nov 2022
Commenté : Walter Roberson
le 11 Nov 2022
Hi all,
I wan to solve the NODE model
function y = NodeModel(tspan,y,theta,inputftrs)
y = tanh(theta.fc1.Weights_state*y+theta.fc1.Weights_input,inputftrs(:,:,tspan.*2)+theta.fc1.Bias);
y = pagemtimes(theta.fc2.Weights,y) + theta.fc2.Bias;
end
Where inputftrs is the input matrix. I called the dlode45 function like this
function X = model(tspan,X0,inputftrs,neuralOdeParameters)
odeModel=@(tspan,X0,neuralOdeParameters)NodeModel(tspan,X0,neuralOdeParameters,inputftrs);
X = dlode45(@odeModel,tspan,X0,neuralOdeParameters,DataFormat="CB");
end
However there comes an error "Unable to apply ODE function."
0 commentaires
Réponse acceptée
Walter Roberson
le 11 Nov 2022
X = dlode45(@odeModel,tspan,X0,neuralOdeParameters,DataFormat="CB");
remove the @ there. odeModel is already a function handle.
2 commentaires
Walter Roberson
le 11 Nov 2022
If you have to interpolate something to use it with any of the ode*() functions, then typically that means that you are violating the mathematical contraints for the ode*() functions. The mathematics of Runge-Kutta is only valid if the equations you give and their first two derivatives are continuous. In most cases, when people interpolate they use linear interpolation, but linear interpolation between lists of points has discontinuous first derivatives.
In order to use interpolation with the ode*() functions you need to use 'cubic' or 'spline' method so that the derivatives get matched up piecewise. This will, of course, only be valid for situations in which you can say that the data values are the results of processes that are continuous, that it is valid for a point between A and B to be influenced both by A and by B. You would not be able to use this kind of interpolation for impulses such as drug dosing, or for road height measurements that reflect stones and other sharp transitions.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!