| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → System Identification Toolbox |
| Contents | Index |
| Learn more about System Identification Toolbox |
| On this page… |
|---|
Resampling Data at the Command Line |
Resampling data signals in the System Identification Toolbox product applies an antialiasing (lowpass) FIR filter to the data and changes the sampling rate of the signal by decimation or interpolation.
If your data is sampled faster than needed during the experiment, you can decimate it without information loss. If your data is sampled more slowly than needed, there is a possibility that you miss important information about the dynamics at higher frequencies. Although you can resample the data at a higher rate, the resampled values occurring between measured samples do not represent measured information about your system. Instead of resampling, repeat the experiment using a higher sampling rate.
Tip You should decimate your data when it contains high-frequency noise outside the frequency range of the system dynamics. |
Resampling takes into account how the data behaves between samples, which you specify when you import the data into the System Identification Tool GUI (zero-order or first-order hold). For more information about the data properties you specify before importing the data, see Importing Data into the GUI.
You can resample data using the System Identification Tool GUI or the resample command. You can only resample time-domain data at uniform time intervals.
Use the System Identification Tool GUI to resample time-domain data. To specify additional options, such as the prefilter order, see Resampling Data at the Command Line.
The System Identification Tool GUI uses idresamp to interpolate or decimate the data. For more information about this command, type help idresamp at the prompt.
To create a new data set by resampling the input and output signals:
Import time-domain data into the System Identification Tool GUI, as described in Importing Data into the GUI.
Drag the data set you want to resample to the Working Data area.
In the Resampling factor field, enter the factor by which to multiply the current sampling interval:
For decimation (fewer samples), enter a factor greater than 1 to increase the sampling interval by this factor.
For interpolation (more samples), enter a factor less than 1 to decrease the sampling interval by this factor.
Default = 1.
In the Data name field, type the name of the new data set. Choose a name that is unique in the Data Board.
Click Insert to add the new data set to the Data Board in the System Identification Toolbox window.
Click Close to close the Resample dialog box.
Use resample to decimate and interpolate time-domain iddata objects. You can specify the order of the antialiasing filter as an argument.
Note resample uses the Signal Processing Toolbox™ command, when this toolbox is installed on your computer. If this toolbox is not installed, use idresamp instead. idresamp only lets you specify the filter order, whereas resample also lets you specify filter coefficients and the design parameters of the Kaiser window. |
To create a new iddata object datar by resampling data, use the following syntax:
datar = resample(data,P,Q,filter_order)
In this case, P and Q are integers that specify the new sampling interval: the new sampling interval is Q/P times the original one. You can also specify the order of the resampling filter as a fourth argument filter_order, which is an integer (default is 10). For detailed information about resample, see the corresponding reference page.
For example, resample(data,1,Q) results in decimation with the sampling interval modified by a factor Q.
The next example shows how you can increase the sampling rate by a factor of 1.5 and compare the signals:
plot(u) ur = resample(u,3,2); plot(u,ur)
When the Signal Processing Toolbox product is not installed, using resample calls idresamp instead.
idresamp uses the following syntax:
datar = idresamp(data,R,filter_order)
In this case, R=Q/P, which means that data is interpolated by a factor P and then decimated by a factor Q. To learn more about idresamp, type help idresamp.
The data.InterSample property of the iddata object is taken into account during resampling (for example, first-order hold or zero-order hold). For more information, see iddata Properties.
Typically, you decimate a signal to remove the high-frequency contributions that result from noise from the total energy. Ideally, you want to remove the energy contribution due to noise and preserve the energy density of the signal.
The command resample performs the decimation without aliasing effects. This command includes a factor of T to normalize the spectrum and preserve the energy density after decimation. For more information about spectrum normalization, see Spectrum Normalization.
If you use manual decimation instead of resample—by picking every fourth sample from the signal, for example—the energy contributions from higher frequencies are folded back into the lower frequencies. Because the total signal energy is preserved by this operation and this energy must now be squeezed into a smaller frequency range, the amplitude of the spectrum at each frequency increases. Thus, the energy density of the decimated signal is not constant.
The following example illustrates how resample avoids folding effects:
% Construct fourth-order MA-process m0 = idpoly(1,[ ],[1 1 1 1]); % Generate error signal e = idinput(2000,'rgs'); e = iddata([],e,'Ts',1); % Simulate the output using error signal y = sim(m0,e); % Estimate signal spectrum g1 = spa(y); % Estimate spectrum of modified signal including % every fourth sample of the original signal. % This command automatically sets Ts to 4. g2 = spa(y(1:4:2000)); % Plot frequency response to view folding effects ffplot(g1,g2) % Estimate spectrum after prefiltering that does not % introduce folding effects g3 = spa(resample(y,1,4)); figure ffplot(g1,g3)
Folding Effects with Manual Decimation

Use resample to decimate the signal before estimating the spectrum and plot the frequency response, as follows:
g3 = spa(resample(y,1,4)); figure ffplot(g1,g3)
The following figure shows that the estimated spectrum of the resampled signal has the same amplitude as the original spectrum. Thus, there is no indication of folding effects when you use resample to eliminate aliasing.
No Folding Effects When Using resample

For a detailed discussion about handling disturbances, see the chapter on preprocessing data in System Identification: Theory for the User, Second Edition, by Lennart Ljung, Prentice Hall PTR, 1999.
![]() | Handling Offsets and Trends in Data | Filtering Data | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |