フィルターのクリア

Model predictive control plots

2 ビュー (過去 30 日間)
K Kalanithi
K Kalanithi 2023 年 12 月 19 日
コメント済み: K Kalanithi 2023 年 12 月 24 日
I am working with model predictive control. How to plot two mpc controllers output in single plot. If I create two mpc controllers by using MPCOBJ command then I wanted to plot two outputs in same plot. otherwise I apply a single mpc controller to two different plants here also i wanted to plot two responses in single plot.

採用された回答

atharva
atharva 2023 年 12 月 19 日
Hey K Kalanithi,
I understand that you want to know how to plot 2 mpc controllers output in a single plot
To plot the outputs of two MPC controllers in a single plot, you can use the sim function to simulate the controllers and then plot the results. Here's an example:
% Create two MPC controllers
mpc1 = mpc(sys1, Ts);
mpc2 = mpc(sys2, Ts);
% Simulate the controllers
T = 10; % Simulation time
r = ones(T, 1); % Reference signal
[y1, ~, u1] = sim(mpc1, T, r);
[y2, ~, u2] = sim(mpc2, T, r);
% Plot the outputs
t = (0:T-1)*Ts; % Time vector
figure;
plot(t, y1, 'b', t, y2, 'r');
xlabel('Time');
ylabel('Output');
legend('MPC 1', 'MPC 2');
In this example, sys1 and sys2 are the plant models, Ts is the sampling time, and T is the simulation time. The sim function is used to simulate the controllers and obtain the outputs y1 and y2. These outputs are then plotted in a single plot using the plot function.
You can go through the MathWorks documentation mentioned below for a better understanding
I hope this helps!
  1 件のコメント
K Kalanithi
K Kalanithi 2023 年 12 月 24 日
Thank you for your answer. it is fruitful for my work.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeModel Predictive Control Toolbox についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by