www.gusucode.com > control 案例程序 matlab源码代码 > control/ValidateTuningResultAgainstRequirementsExample.m
%% Validate Tuning Result Against Requirements % Validate a control system tuned with |systune| to determine whether small % violations of tuning requirements are acceptable. % % When you tune a control system using tuning commands such as |systune|, % use |viewSpec| to compare the tuned result against the tuning requirements. % Doing so can help you determine whether the tuned system comes sufficiently % close to meeting your soft requirements. %% % Open a Simulink(R) model that contains a control system you want to tune. open_system('rct_airframe2') %% % Create requirements for tuning the control system. For this example, % use tracking, roll-off, stability margin, and disturbance rejection % requirements. Req1 = TuningGoal.Tracking('az ref','az',1); Req2 = TuningGoal.Gain('delta fin','delta fin',tf(25,[1 0])); Req3 = TuningGoal.Margins('delta fin',7,45); MaxGain = frd([2 200 200],[0.02 2 200]); Req4 = TuningGoal.Gain('delta fin','az',MaxGain); %% % Tune the model using these tuning requirements. ST0 = slTuner('rct_airframe2','MIMO Controller'); addPoint(ST0,'delta fin'); rng('default'); [ST1,fSoft] = systune(ST0,[Req1,Req2,Req3,Req4]); %% % |ST1| is a tuned version of the |slTuner| interface to the control system. % |ST1| contains the tuned values of the tunable parameters of the MIMO % controller in the model. %% % Verify that the tuned system satisfies the margin requirement. figure; viewSpec(Req3,ST1) %% % The yellow region denotes margins that do not satisfy the requirement. % The red plot represents the actual stability margin of the tuned system, % |ST1|. The blue plot represents the margin used in the optimization calculation, % which is an upper bound on the actual margin. For |ST1|, the plot indicates % that the margin requirement is satisfied at all frequencies. %% % Validate the tracking and disturbance rejection requirements in the frequency % domain. figure viewSpec([Req1,Req4],ST1) %% % When you provide a vector of requirements, |viewSpec| puts all the requirements % into a single figure window. %% % The first plot shows that the tuned system very nearly meets the tracking % requirement. The slight violation suggests that setpoint tracking will % perform close to expectations. %% % The second plot shows that the disturbance rejection levels off in violation % of the requirement at very low frequencies. A small bump near 35 rad/s % suggests possible damped oscillations at this frequency. %% % Use |step| and |getIOTransfer| to examine setpoint tracking and disturbance % rejection in the time domain.