importing and preprocessing experiment data (gui) -凯发k8网页登录
this example shows how to create an estimation experiment from measured data stored in a file and how to preprocess the measured data. you use the imported data to estimate the parameters of a simple rc circuit.
this example requires simscape™ software.
rc circuit model
the simulink® model, sdorccircuit
, models a simple resistor-capacitor (rc) circuit.
open_system('sdorccircuit');
you use measured data to estimate the rc model parameter and state values.
measured output data:
capacitor voltage, output of the ps-simulink converter block
parameter:
capacitance,
c1
, used by the c1 block
state:
initial voltage of the capacitor
define the estimation experiment
in this example, you load the measured data from a saved matlab® file. the data is also stored in a comma separated variable (csv) text file. you can also load the measured data directly from text or excel® files.
first load the measured data from the matlab file, the file defines two variables, time
and data
that specify the measured capacitor voltage.
load sdorccircuit_experimentdata
to launch the parameter estimator, in the simulink model window, in the apps gallery, under control systems, click parameter estimator.
click new experiment to create an estimation experiment that contains the measured data. a variable exp
is created in the parameter estimator and a dialog to edit the experiment opens.
the experiment editor contains sections to specify measured output data and sections to optionally specify experiment initial states and parameters.
the experiment editor automatically adds measured output signals for model root level ports and logged model signals. click select signals to add additional measured outputs if needed. for this example the capacitor voltage signal is logged in the model and already added to the experiment.
specify the measured capacitor voltage by typing [time data]
in the edit field. this uses the matlab variables time
and data
loaded from file earlier to specify the measured capacitor voltage. measured data is specified as a matrix where the 1st column is time and subsequent columns signal data.
alternatively, you can specify the measured capacitor voltage variables by loading the measured data directly from text or excel files. click the import button to open a file browser and select sdorccircuit_experimentdata.csv
file.
a tool for importing column data from a file opens. the first column selected for import is used to specify the signal time, subsequent columns selected for import are used to specify the signal data. select the time
and data
columns and click import selection.
in the experiment editor click plot & simulate to plot the measured experiment data and the simulated model response.
the experiment plot shows that the simulated data does not match the measured data. the plot also shows that the model initial state is not correct and needs to be estimated (the measured and simulated voltages at time 0 are significantly different). from the experiment editor, click select initial states to open a dialog to select model initial states; select the sdorccircuit.c1.vc
state and click ok to add the state to the experiment.
preprocess the experiment data
the measured data contains high frequency noise that you can remove using a low-pass filter. click the experiment plot tab and select low pass filter.
this opens the low-pass filter tool. the upper axis shows the signal fft, the lower axis shows the signals. the original signal is shown in blue and the filtered signal in red. adjust the filter bandwidth by either typing a value in the normalized cutoff frequency edit field or clicking and dragging the yellow patch edge. drag the filter cutoff to 0.4. click options and select zero-phase shift filter to avoid introducing the filter phase shift into the measured data.
click apply and close low-pass filter to complete low-pass filtering of the data. the experiment is updated with the filtered signal. you can use other preprocessing tools such as remove offset, scale, and resample to further process the measured data. for this example low-pass filtering is sufficient.
estimate model parameter values
with the experiment data configured and preprocessed you can now run an estimation. first select parameters to estimate. click the parameter estimation tab and select select parameters. a dialog to specify model parameters for estimation opens. click select parameters and select, c1
, the circuit capacitor value. set the capacitor minimum value to 0 and the initial guess to 460e-6.
click estimate to start the estimation. you can modify estimation options by setting the cost function combobox and clicking more options.
while the estimation is running, the plots update and a dialog showing estimation progress appears. the progress dialog shows the estimation iterations, the number of times the model has been evaluated (f-count), and the estimation cost at each iteration.
after a number of iterations the estimation converges and terminates. the model is updated with the estimated parameters and the estimation results are saved in the data browser.
related examples
to learn how to estimate model parameters using the sdo.optimize
command, see .
close the model.
bdclose('sdorccircuit')