Filter löschen
Filter löschen

How can I change the label after using my sim function

1 Ansicht (letzte 30 Tage)
Jialu Yao
Jialu Yao am 15 Okt. 2023
Kommentiert: Jialu Yao am 16 Okt. 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);
-->"Weights.ManipulatedVariables" is empty. Assuming default 0.00000. -->"Weights.ManipulatedVariablesRate" is empty. Assuming default 0.10000. -->"Weights.OutputVariables" is empty. Assuming default 1.00000. for output(s) y1 y2 and zero weight for output(s) y3
% 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)
-->Assuming output disturbance added to measured output #1 is integrated white noise. -->Assuming output disturbance added to measured output #2 is integrated white noise. -->Assuming output disturbance added to measured output #3 is integrated white noise. -->"Model.Noise" is empty. Assuming white noise on each measured output.
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?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 15 Okt. 2023
Verschoben: Walter Roberson am 15 Okt. 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);
-->"Weights.ManipulatedVariables" is empty. Assuming default 0.00000. -->"Weights.ManipulatedVariablesRate" is empty. Assuming default 0.10000. -->"Weights.OutputVariables" is empty. Assuming default 1.00000. for output(s) y1 y2 and zero weight for output(s) y3
% 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)
-->Assuming output disturbance added to measured output #1 is integrated white noise. -->Assuming output disturbance added to measured output #2 is integrated white noise. -->Assuming output disturbance added to measured output #3 is integrated white noise. -->"Model.Noise" is empty. Assuming white noise on each measured output.
figs = get(0,'Children');
T = findall(figs, 'string', 'Plant Outputs')
T =
Text (Plant Outputs) with properties: String: 'Plant Outputs' FontSize: 11 FontWeight: 'bold' FontName: 'Helvetica' Color: [0 0 0] HorizontalAlignment: 'center' Position: [277.5003 356.7500 -0.8087] Units: 'pixels' Use GET to show all properties
Tax = T.Parent
Tax =
Axes (Plant Outputs) with properties: XLim: [0 1] YLim: [0 1] XScale: 'linear' YScale: 'linear' GridLineStyle: '-' Position: [0.0665 0.0830 0.9575 0.8154] Units: 'normalized' Use GET to show all properties
Tax.Tag
ans = 0×0 empty char array
Tax.Title
ans =
Text (Plant Outputs) with properties: String: 'Plant Outputs' FontSize: 11 FontWeight: 'bold' FontName: 'Helvetica' Color: [0 0 0] HorizontalAlignment: 'center' Position: [277.5003 356.7500 -0.8087] Units: 'pixels' Use GET to show all properties
Tax.HandleVisibility
ans = 'off'
In summary, the name Plant Outputs is a Title within a hidden axes. You can findall() it and then change its String property.

Weitere Antworten (0)

Kategorien

Mehr zu Fluid Dynamics finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by