Clear Filters
Clear Filters

Matrix input for Delayed Differential Equations

1 view (last 30 days)
d7366431
d7366431 on 25 Dec 2018
Edited: d7366431 on 25 Dec 2018
Hello, could you please help me with solving system of Delayed Differential equations with matrix input?
Initially my equation is looks like
τ - constant delay
X - is vector of n elements
c - constant
- diag. matrix of n elements
- vector of zeros, only first element is equal to
I decided to choose DDE23 solver, but I'm not sure is it correct or not. Would be great to here some comments.
I put "lags" as constant = [1], I'm not sure is it correct or not, my idea was to get data from previous timestep which is in my case is 1 as I put in tspan vector.
Also I decrease order of differential equation as
Could you please tell me is it correct solver for this task? I noticed that nothing is changes with changing delay value.
How can I display movement of last element of my system (n th element). Is it correct way how I did below?
Below is my Matlab Code with some comments:
tspan = 1:1:5;
%%sol = dde23( ddefile, lags, history, tspan);
sol = dde23( @dde, [1], @history, tspan);
ax1 = subplot(2,1,1);
plot(sol.x,sol.y);
grid on;
title('sol.x, sol.y')
xlabel('time t');
ylabel('x(t)');
ax2 = subplot(2,1,2);
grid on;
title('deval')
xplot = 1:1:10;
yplot = deval(sol,xplot,size(n));
plot(xplot,yplot);
xlabel('time t');
ylabel('x(t)');
function xdot=dde(t,x,Z) % x - state of system (position of each block)
n=3; %number of elements for simplicity put 3 for now
v0=zeros(n,1);
v0(1)=1;
% c matrix
c=1;
C=zeros(n);
C(end,end)=c;
% D Matrix
d=1;
D=d*eye(n);
% M Matrix
m=1;
M=m*eye(n);
%% The differential equations:
xlag = Z(1:n,1);
x1 = zeros(n,1);
x2 = zeros(n,1);
x1dot = zeros(n,1);
x2dot = zeros(n,1);
xdot = zeros(2*n,1);
x1 = xdot(1:n);
x2 = xdot(n+1:end);
x1dot = x2;
x2dot = v0*t-M*xlag-D*x1-C*x2;
xdot = [x1dot; x2dot];
end
function s = history(t)
n=3
s=zeros(2*n,1)
for i=1:2*n
s(i,1)=1;
end
end
  4 Comments
madhan ravi
madhan ravi on 25 Dec 2018
Basically I don't see any equations at all , all I see is zeros in those equations
d7366431
d7366431 on 25 Dec 2018
Edited: d7366431 on 25 Dec 2018
May be I was not clear, sorry, the Idea here is to put the values later on for constants c, v0, m, d and have some solution of initial equation:

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!