Borrar filtros
Borrar filtros

How can I change the label after using my sim function

1 visualización (últimos 30 días)
Jialu Yao
Jialu Yao el 15 de Oct. de 2023
Comentada: Jialu Yao el 16 de Oct. de 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?

Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Oct. de 2023
Movida: Walter Roberson el 15 de Oct. de 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.

Más respuestas (0)

Categorías

Más información sobre Fluid Dynamics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by