How can I change the label after using my sim function
1 view (last 30 days)
Show older comments
A = [0.9607, 0.0196, 0.1776; -0.0098, 0.9999, -0.0009; 0, 0, 0.8187];
B = [0.0185, 0.1974; -0.0001, 0.1390; 0.1813, 0];
C = [1, 0, 0; 0, 1, 0; 0, 0, 1];
Ts = 0.2;
sys = ss(A, B, C, 0, Ts);
% States : HP = Head Perturbation; SP = Stock-level Perturbation; AP = Air
% Valve Perturbation
% Controls: AV = Air Valve; SV = Stock Valve
model = setmpcsignals(sys,'MV',[1,2],'MO',[1,2,3]);
% controller object, sampling period, prediction hor., control hor.
mpcobj = mpc(model, Ts, 10, 10);
% Input constraints
mpcobj.MV(1,1).Min = -5;
mpcobj.MV(1,1).Max = 5;
mpcobj.MV(1,2).Min = -10;
mpcobj.MV(1,2).Max = 10;
% Output Constraints
mpcobj.OV(1,1).Min = 0;
mpcobj.OV(1,1).Max = 50;
mpcobj.OV(1,2).Min = 0;
mpcobj.OV(1,2).Max = 25;
Tstop = 30; % simulation time
Tf = round(Tstop/Ts); % number of simulation steps
r = 10*ones(Tf,3); % reference signal
sim(mpcobj,Tf,r)
This is my matlab code for MPC. After I use the sim function there are two graphs and I would like to change the label of them. If I use title, I can only change one of them. is there a way that I can directly change the titles without using several plot functions and regenerate my graphs?
0 Comments
Accepted Answer
Walter Roberson
on 15 Oct 2023
Moved: Walter Roberson
on 15 Oct 2023
A = [0.9607, 0.0196, 0.1776; -0.0098, 0.9999, -0.0009; 0, 0, 0.8187];
B = [0.0185, 0.1974; -0.0001, 0.1390; 0.1813, 0];
C = [1, 0, 0; 0, 1, 0; 0, 0, 1];
Ts = 0.2;
sys = ss(A, B, C, 0, Ts);
% States : HP = Head Perturbation; SP = Stock-level Perturbation; AP = Air
% Valve Perturbation
% Controls: AV = Air Valve; SV = Stock Valve
model = setmpcsignals(sys,'MV',[1,2],'MO',[1,2,3]);
% controller object, sampling period, prediction hor., control hor.
mpcobj = mpc(model, Ts, 10, 10);
% Input constraints
mpcobj.MV(1,1).Min = -5;
mpcobj.MV(1,1).Max = 5;
mpcobj.MV(1,2).Min = -10;
mpcobj.MV(1,2).Max = 10;
% Output Constraints
mpcobj.OV(1,1).Min = 0;
mpcobj.OV(1,1).Max = 50;
mpcobj.OV(1,2).Min = 0;
mpcobj.OV(1,2).Max = 25;
Tstop = 30; % simulation time
Tf = round(Tstop/Ts); % number of simulation steps
r = 10*ones(Tf,3); % reference signal
sim(mpcobj,Tf,r)
figs = get(0,'Children');
T = findall(figs, 'string', 'Plant Outputs')
Tax = T.Parent
Tax.Tag
Tax.Title
Tax.HandleVisibility
In summary, the name Plant Outputs is a Title within a hidden axes. You can findall() it and then change its String property.
More Answers (0)
See Also
Categories
Find more on Fluid Dynamics 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!