How can I enter a variable disturbance as a matrix input
7 views (last 30 days)
Show older comments
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 .
0 Comments
Answers (1)
Suraj Kumar
on 4 Mar 2025 at 3:37
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!
0 Comments
See Also
Categories
Find more on Control System Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!