# Matrix input for Delayed Differential Equations

2 Ansichten (letzte 30 Tage)
d7366431 am 25 Dez. 2018
Bearbeitet: d7366431 am 25 Dez. 2018
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 = , 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, , @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 Kommentare3 ältere Kommentare anzeigen3 ältere Kommentare ausblenden
d7366431 am 25 Dez. 2018
Bearbeitet: d7366431 am 25 Dez. 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: Melden Sie sich an, um zu kommentieren.

### Kategorien

Find more on Programming in Help Center and File Exchange

R2018b

### Community Treasure Hunt

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

Start Hunting!