How to solve this ode equation where one of the inputs has some delay and equation has written in matrix form in MATLAB ode45?
Ältere Kommentare anzeigen
I solved this ode for constant input u. Function script of this ode is written here-
function dx = mySystem(t,x,u,A,B)
dx = A*x +B*u
end
A is (6*6) matrix. B is (4*6) matrix. C is (6*1) matrix. D is (4*1) matrix.
Main Script
A=[ -0.1078 0 0 0 -10 0; 0 -0.0898 0 0 0 -8.3333; 0 0 -0.2352 0 10 0; 0 0 0 -0.196 0 8.3333; 1 0 -1 0 0 0; 0 1 0 -1 0 0];
B=[0.3313 0 -8.9335 0; 0 0.2761 0 -7.4446; 0 0 3.7249 0;0 0 0 3.104; 0 0 0 0; 0 0 0 0];
C=[ 0 0 1.4206 1.4206 0 0]; D= [0 0 -15 -15];
u=zeros(2*2,1);
for i=1:2
u(i)=0.5;
end
fun = @(t, x) mySystem(t, x, u, A, B);
tspan = [0, 20]; % Time span
x0 = zeros(3*3,1); %Initial Condition
[t, YSol] = ode45(fun, tspan, x0); % ode
Pe=C*YSol(:,1:3*2)'+D*u; % Output Equation
% Plot
figure(5)
plot(t,Pe);
xlabel('time'); ylabel('{P');
title(' Change in P')
Above ode has been solved easily. But actually my system has delayed input. u(1)=0.5 is constant but u(2)=0.5*(tau-5), i.e. u(2) is delayed by 10 second. In this situation how can I solve this? What will be the modified code? Other thing is if the system have more than 100 order then how it can be solved? A is (3*n by3*n); B is(3*n by 2*n); C is (1 by 3*n);D is (1 by 2*n); where n=100, and out of 2*n input u(2):u(n) have delay of different tau.
%% Delay in Input
u(1)=0.5;
if t <= 10
u(2)=0;
else
u(2)=0.5;
end
1 Kommentar
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Programming finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!