How can I enter a variable disturbance as a matrix input

4 views (last 30 days)
the following system contains linear system and a augmented representation, how do I inlude the same disturbance knowing that it is a function of x1(t) and x2(t)m and occures in a specific time in a form of matrix to respect the appropriate dimensions .

Answers (1)

Suraj Kumar
Suraj Kumar on 4 Mar 2025
To include a variable disturbance in a MATLAB system, especially when dealing with state-space representations or augmented systems, you need to appropriately define the disturbance as a function of your state variables and incorporate it into your system equations.
1. Define the disturbance (d(t)) as a function of the state variables ( x_1(t) ) and ( x_2(t) ) that occurs at specific times.Replace f1 and f2 with your specific disturbance functions and t_start and t_end with the times during which the disturbance occurs.
function d = disturbance(t, x)
if t >= t_start && t <= t_end
d = [f1(x(1), x(2)); f2(x(1), x(2))];
else
d = [0; 0];
end
end
2. Use a numerical solver to simulate the system dynamics, including the disturbance.
t_span = [0, T]; % where T is the total simulation time
x0 = [x1_0; x2_0]; % Replace with your initial state conditions
function dxdt = system_dynamics(t, x)
% System matrices
A = [...]; % Define your A matrix
B = [...]; % Define your B matrix
E = [...]; % Define your E matrix
u = ...; % Define your control input
% Disturbance
d = disturbance(t, x);
% State equation
dxdt = A*x + B*u + E*d;
end
[t, x] = ode45(@system_dynamics, t_span, x0);
Hope this helps!
  1 Comment
Mohamed Amine TAIB
Mohamed Amine TAIB on 26 Mar 2025
Dear Suraj!
Thank you very much for your help. I actually graduated three years ago and now i am working as an eletrical Engineer. This question was for my master's degree project. I wish you the best.

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!