Collect Frequency Response Experiment Data for Offline Estimation
此示例显示了如何使用频率响应估计器块执行频率响应估计实验,并存储数据以使以后的估计离线。实际上,当您的部署环境缺乏在线估算计算的资源时,您可以使用这种方法实时对实体工厂进行实验。在此示例中,出于说明目的,您可以在Simulink®建模的植物上执行实验。金宝app
Model and Experiment Parameters
This example uses a model that already contains a Frequency Response Estimator block configured to collect experiment data for offline estimation.
Open the model.
mdl ="CollectFreqRespEstimDataEx.slx"; open_system(mdl)
这model contains a plant in a closed-loop configuration with a PI controller. The Frequency Response Estimator block accepts the control signal as the inputu
。It feeds the control signal plus a perturbation into the plant input.
这Frequency Response Estimator block is configured to run the experiment in sinestream mode, with the same experiment parameters used in the exampleOnline Frequency Response Estimation During Simulation。In this example, however, the估计模式参数设置为Offline。In this configuration, block injects the specified perturbation signals and collects the response data, but does not perform the estimation. The block is configured to use a sinestream signal at the frequenciesw = logspace(0,2,20)
。
Collect Experiment Data
Simulate the model. The block performs the experiment and collects the response data. The scope shows the applied sinestream signal and the system response.
sim(mdl) open_system(“ collectfreqrespestimdataex/scope1')
该模型被配置为记录块输出端口处的估计数据数据
(seeExport Signal Data Using Signal Loggingfor information about data logging). The data is stored in the MATLAB workspace as theSimulink.SimulationData.Dataset
objectlogsout
。Because数据
is the only logged port, you can access the logged data in the first entry inlogsout
。这Values
该条目的字段是包含四个字段的结构。
logdata = logsout{1}.Values
logdata =带有字段的结构:准备:[1x1次数]扰动:[1x1次数]植物indut:[1x1 limeseries] plantOutput:[1x1 limeseries]
这Ready
field is a timeseries containing a logical signal that indicates which time steps contain the data to used for the estimation. For a sinestream signal, this field indicates which perturbation periods for the estimation to discard (settling periods).Perturbation
contains the sinestream perturbation applied to the plant. ThePlantInput
和工厂输出
timeseries contain the signals at the block inputsu
和y
, respectively.
Estimate Frequency Response
If you collect this data in a deployed environment with limited computational resources, you can use the data to perform frequency response estimation offline, using thefrestimate
command. Givefrestimate
thelogdata
structure and the same frequencies you used for theFrequencies块中的参数。frestimate
过程logdata
to obtain a frequency response data (frd
) model containing the estimated responses at those frequencies.
sys_estim = frestimate(logdata,w,'rad/s');尺寸(sys_estim)
FRD model with 1 outputs, 1 inputs, and 20 frequency points.
Examine the estimated frequency response.
figure bode(sys_estim,'B*')