Iterating in function handles

I am trying to solve an SDE (using SDETools). Here is a simplified version of the SDE.
I need to input function handles, f and g, for the 'dt' and 'dw' components respectively. For example,
g = @(t, x) sig;
would define the function handle for g given a pre-defined array sig. Now, I would like to define the function handle , where are coefficients that depend on i and j. For the purpose of this example, assume that. How can I define a single function handle that returns a column vector that does what I want?
If it helps, when , I was able to do
f = @(t, x) mean(x) - x;
But I'm stuck on how to adapt this to include the . I think I need to iterate over i and j inside the function, but don't know if this is correct. Thanks in advance.

4 Kommentare

Torsten
Torsten am 13 Mär. 2022
Don't use function handles for compliciated expressions. Write functions instead.
Harry Li
Harry Li am 13 Mär. 2022
The problem is that I need to input f as a function handle for the SDE solver.
Torsten
Torsten am 13 Mär. 2022
Bearbeitet: Torsten am 13 Mär. 2022
Yes, but the function handle can point to a function.
f = @(t,x)fun(t,x)
%Call SDE with function handle f
function res = fun(t,x)
% Calculate whatever you like
res = something;
end
Harry Li
Harry Li am 13 Mär. 2022
That makes sense, thank you.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2022a

Gefragt:

am 13 Mär. 2022

Kommentiert:

am 13 Mär. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by