Model predictive control plots
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
K Kalanithi
am 19 Dez. 2023
Kommentiert: K Kalanithi
am 24 Dez. 2023
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.
0 Kommentare
Akzeptierte Antwort
atharva
am 19 Dez. 2023
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!
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Controller Creation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!