Hi Bowei,
You should be able to create a new ODE function that has only three inputs as required. Let me show a few cases.
Case 1 - ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/873395/image.png)
In this case you can define
. Assuming you have f as a function handle you can define g in code with: g = @(t,x,theta) f(t,x,theta,e(t))
Then solve using g in dlode45.
Case 2 - ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/873405/image.png)
This is a special case of case 1:
g = @(t,x,theta) f(t,x,theta) + e(t)
Call dlode45 with g.
Case 3 -
for ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/873415/image.png)
In this case you have an extra hyperparameter i which you just have to select a specific value for. For example let
and
. You could write this in code as: e = @(t,i) cos(i*t);
f = @(t,x,A,i) A*x + e(t,i);
x0 = dlarray(randn());
tspan = [0,1];
A = dlarray(randn());
i = 3;
x = dlode45(@(t,x,A) f(t,x,A,i), tspan, x0, A, DataFormat="CB");
Note that in this case you can loop over the values you want for i.
Hope that helps,
Ben