Matrix input for Delayed Differential Equations
1 次查看(过去 30 天)
显示 更早的评论
Hello, could you please help me with solving system of Delayed Differential equations with matrix input?
Initially my equation is looks like ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199720/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199720/image.png)
τ - constant delay
X - is vector of n elements
c - constant
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199721/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199722/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199723/image.png)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199724/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199725/image.png)
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 个评论
madhan ravi
2018-12-25
Basically I don't see any equations at all , all I see is zeros in those equations
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!