how to define mpc object's plant as state space ?
1 次查看(过去 30 天)
显示 更早的评论
how to define the mpc object's plant as state space rather than transfer function. i tried to run this code but not working.
% Define system matrices (Ad, Bd, Cd, Dd) for the quadruple tank system
Ad = [-0.0173190, 0, 0.026219, 0; 0, -0.0113455, 0, 0.017708; 0, 0, -0.026219, 0; 0, 0, 0, -0.017708];
Bd = [0.0395, 0; 0, 0.03598; 0, 0.076375; 0.06378, 0];
Cd = [1, 0, 0, 0; 0, 1, 0, 0];
Dd = [0, 0; 0, 0];
% Define prediction and control horizons
predictionHorizon = 10; % Adjust as needed
controlHorizon = 3; % Adjust as needed
% Define constraints (input and state constraints)
inputConstraints = [-10, 10; -10, 10]; % Adjust as needed
stateConstraints = [0, 40; 0, 40; 0, 40; 0, 40]; % Adjust as needed
% Define cost function weights
Q = eye(4); % State weight matrix (adjust as needed)
R = eye(2); % Input weight matrix (adjust as needed)
% Initial state
x0 = [10; 10; 10; 10]; % Adjust the initial state as needed
% MPC setup
mpcobj = mpc(Ad, Bd, Cd, Dd, 'PredictionHorizon', predictionHorizon, 'ControlHorizon', controlHorizon);
0 个评论
采纳的回答
Sam Chak
2023-10-19
Hi @AMAN
There was an incorrect syntax issue with mpc(), but it is now fixed below:
% Define system matrices (Ad, Bd, Cd, Dd) for the quadruple tank system
Ad = [-0.0173190, 0, 0.026219, 0; 0, -0.0113455, 0, 0.017708; 0, 0, -0.026219, 0; 0, 0, 0, -0.017708];
Bd = [0.0395, 0; 0, 0.03598; 0, 0.076375; 0.06378, 0];
Cd = [1, 0, 0, 0; 0, 1, 0, 0];
Dd = [0, 0; 0, 0];
sys = ss(Ad, Bd, Cd, Dd) % <-- added this
% Define prediction and control horizons
predictionHorizon = 10; % Adjust as needed
controlHorizon = 3; % Adjust as needed
% Define constraints (input and state constraints)
inputConstraints = [-10, 10; -10, 10]; % Adjust as needed
stateConstraints = [0, 40; 0, 40; 0, 40; 0, 40]; % Adjust as needed
% Define cost function weights
Q = eye(4); % State weight matrix (adjust as needed)
R = eye(2); % Input weight matrix (adjust as needed)
% Initial state
x0 = [10; 10; 10; 10]; % Adjust the initial state as needed
% MPC setup
ts = 0.1; % <-- added this
mpcobj = mpc(sys, ts, predictionHorizon, controlHorizon) % <-- fixed this
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Model Predictive Control Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!