I have a system of DEs similar to the following:
If the variable Z is not present (i.e. eq (3) also), then I can solve it using ode45 command.
But the availability of Z is creating problem for me. To get the value of Z at time t, we have to solve the ODE (3) from time 0 to \tau, then we have to put that value of Z in equation (2), for evey instance 't'.
The main problem is, while solving DE using ode45, at any instance t, MATLAB uses the values of variables at that instance only. But here we require values of variables at time (t-\tau) to use at time t.
Please help me to solve the problem. Thanks in advance.
MTLB-page.jpg

2 Kommentare

darova
darova am 29 Jul. 2019
Can you please attach your script?
Ashok Das
Ashok Das am 29 Jul. 2019
Bearbeitet: Ashok Das am 29 Jul. 2019
Main function is:
X_0 = 1; Y_0 = 1; % Initial condition
t = linspace(0,10); %TIme
[t, Var] = ode45(@myfun, t, [X_0 Y_0]); % ODE solve
X= Var(:,1);
Y= Var(:,2);
Create myfun :
function [dX dY] = myfun(t, IC)
X= IC(1); Y=IC(2);
a=1; b=2; c=3; d=4; % Values
dX = a*X + b*Y;
% Now here before this line I need to solve the DE
% (3) upto time t= \tau to get the value of Z
% (which I am not able to do).
dY = c*X+ d*Y + Z;
end

Melden Sie sich an, um zu kommentieren.

Antworten (2)

darova
darova am 29 Jul. 2019
Bearbeitet: darova am 29 Jul. 2019

0 Stimmen

What if just solve 2 systems?
First one (t <= tau) with initial conditions: X(0) = X0, Y(0) = Y0
[t, Var] = ode45(...); % ODE solve
X= Var(:,1);
Y= Var(:,2);
x0 = X(end); % initial conditions for 2d system
y0 = Y(end);
Second (t >= tau) with Z(tau) = Z0 (X and Y initial conditions give from the first solution)
What do you think about my idea?

4 Kommentare

Ashok Das
Ashok Das am 29 Jul. 2019
The problem is that, for the equation (3), the value of Z and its derivative is at time t' , but the variables X and Y are considered at time (t' +t - \tau).
darova
darova am 29 Jul. 2019
How t' depends on t? If t = tau+0.5, what will be t'?
Are you sure about correctness of (t' +t -tau)?
Ashok Das
Ashok Das am 29 Jul. 2019
In equation (3), t' is the only independent variable. t and \tau are constant regarding to equation (3). We have to solve (3) for t' =0 to t' = \tau, and fit that value in eqaution (2)
Ashok Das
Ashok Das am 29 Jul. 2019
If t = tau+0.5, then (t' +t -tau)= t' +0.5 .
The value of \tau is fixed throughout the simulation.
We have to find Z at t' = \tau for each value of t.

Melden Sie sich an, um zu kommentieren.

Steven Lord
Steven Lord am 29 Jul. 2019

0 Stimmen

I only skimmed your problem but it looks like when Z is not present, you have a set of ordinary differential equations. Once Z comes into the picture, you no longer have a set of ordinary differential equations. Your equations are now delay differential equations. Use the ODE solvers to solve the system until t reaches tau, then use the DDE solvers (like dde23 or ddesd) to solve the system using the results from the ODE solvers as the history.

Kategorien

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

Gefragt:

am 29 Jul. 2019

Beantwortet:

am 29 Jul. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by