How do I define a dynamic system in matlab with two state variables as output to be controlled, one control input and one fixed input for the MPC controller block?

14 visualizaciones (últimos 30 días)
This is the vehicle dynamic system equation where x is state vector with two state variables which are to be controlled. A, E and B are constant matrices. u is a control input which is yaw moment is this case and is an input which is fixed. I have to define this system in MATLAB to give it as internal plant model to the MPC block in simulink. Do I consider as measured disturbance if I merge u and in one matrix making it as two input two output system or is there any other method to define the system ?
How do I define the system in state space form so that I can give it to MPC controller block as internal plant model?

Respuestas (1)

Sanju
Sanju el 22 de Nov. de 2023
I understand that you want to know how to define a dynamic system in MATLAB with two state variables,
The state-space representation is typically given as,
x˙=Ax+Bu+Ew
where ”w” is the process disturbance.
Regarding your question about whether to consider “δf” as a measured disturbance, it depends on whether you have a sensor that can measure it. If you do, then you can include it as a measured disturbance. Otherwise, you can treat it as an unmeasured disturbance.
To define the system in state space form, you can use the following code:
% Define the system matrices
A = [a11 a12; a21 a22];
B = [b1; b2];
E = [e11 e12; e21 e22];
C = eye(2);
% Define the state space model
sys = ss(A, [B E], C, 0);
% Display the state-space model
disp('State-Space Model:')
disp(sys)
% Save the system to a MATLAB file
save('vehicle_system.mat', 'sys');
Here, “a11”, “a12”, “a21”, “a22”, “b1”, “b2”, “e11”, “e12”, “e21”, and “e22” are the elements of the matrices “A”, “B”, and “E”. The State Space function is used to create a state-space model. The “[B E]” input matrix combines the control input “u” and the fixed input “δf” into a single input vector.
To create the Simulink model, you can follow these steps:
  1. Open Simulink and create a new model.
  2. Drag and drop the "State-Space" block from the Simulink Library Browser onto the model canvas.
  3. Double-click the "State-Space" block to open its block parameters dialog.
  4. Enter the system matrices “A”, “E”, and “B” into the appropriate fields.
  5. Connect the output of the "State-Space" block to the input of the MPC controller block.
  6. Connect the output of the MPC controller block to the input of the plant block.
  7. Add any other necessary blocks to the model, such as disturbance inputs or output signals.
  8. Save the model with a name of your choice.
Hope this Helps!
Thanks.

Categorías

Más información sobre Controller Creation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by