How to apply time varying input with dlode45?
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2022-11-11
X = dlode45(@odeModel,tspan,X0,neuralOdeParameters,DataFormat="CB");
remove the @ there. odeModel is already a function handle.
2 个评论
Walter Roberson
2022-11-11
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.
更多回答(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!