Frage

The equations looks like this:

dxi(t)/dt = -c * xi(t) * yi(t)

dyi(t)/dt = a * Σ{i=1 to n}(xi(t) * yi(t)) + xi(t) * yi(t - 1) + b

where a, b and c are whatever constant values you want, for example a=1, b=2, c=3.

Σ{i=1 to n}(xi(t) * yi(t)) means summation from i=1 to n, for example n=3: x1(t)*y1(t) + x2(t)*y2(t) + x3(t)*y3(t)

So, how can I express & solve this using matlab?

War es hilfreich?

Lösung

You need to build what is called a delayed differential equation. I was about to explain how to do, but then I found this wonderful tutorial to do just that. Example 1 is basically what you need.

The only extra caveat is that you should incorporate dx/dt and dy/dt into the same set of differential equation

Let me know if you need more help

Edit: keep it in one file

function  dYdt = ddefun(t,Y,Z)
    % assume Y = [x;y]
    x = Y(1:n); % 2n is the size of Y. this step is unnecessary ...
    y = Y(n+1:2*n); % but helps visualize what is happening

    ytau = Z(:,1);

    dYdt(1:n) = -c*x.*y;
    dYdt(n+1:2*n) = a*dot(x,y) + x.*ytau + b

end

Andere Tipps

If you're looking for a numerical solution (which means you need initial conditions also), the most common solver used is ode45. The link gives examples on how to express specific ODEs.

Later Edit: For the term yi(t−1) you may want to integrate your function in "chunks" of length 1 for t — e.g. t ∈ { [0,1], [1,2], [2,3]... } — and using the previously found solution as coefficient in the actual time "chunk." Like this the solutions "feed" from themselves, and you won't be bothered by the convolution. Of course, one needs to consider yi(t−1) = 0 (or other known function) in the initial iteration.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top