필터 지우기
필터 지우기

How to apply time varying input with dlode45?

조회 수: 3 (최근 30일)
Emebet Gedlu
Emebet Gedlu 2022년 11월 11일
댓글: Walter Roberson 2022년 11월 11일
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."

채택된 답변

Walter Roberson
Walter Roberson 2022년 11월 11일
X = dlode45(@odeModel,tspan,X0,neuralOdeParameters,DataFormat="CB");
remove the @ there. odeModel is already a function handle.
  댓글 수: 2
Emebet Gedlu
Emebet Gedlu 2022년 11월 11일
Thank you. I found also I have to interpolate the input matrix to the ode time step.
Walter Roberson
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 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