filter
Description
This function requires Extended Tire Features for Vehicle Dynamics Blockset.
obj=filter(obj,Name=Value)tireData object specified by obj. The function
        applies a zero-phase digital filter unless you specify a moving mean to filter the data
        using the name-value argument k. Signal Processing Toolbox™ is required for zero-phase digital filter calculations. For more information,
        see filtfilt (Signal Processing Toolbox).
Note
Data channels with NaN values are not filtered.
Examples
Use the filter function to remove noise from tire measurement data. Set combinations of these name-value arguments to specify the filter design:
- k— Moving mean, where- kis the window length for local k-point mean values
- d—- digitalFilterobject
- b,- a— Transfer function coefficients
- F,- Fs— Cutoff frequency and optional sampling frequency for a low-pass filter
Unless you specify a moving mean, this example requires the Signal Processing Toolbox.
Import and View Tire Measurement Data
Import tire measurement data into a tireData object, td.
td = tireData("example_data.tdx");Multiple Fz conditions are included in the data. Use the split function to separate the data by tire data channel Fz, resulting in four tireData objects.
td = split(td,"Fz");Use the plot function to view the normal force versus the elapsed time using the normal force to assign colors and legend values.
plot(td,DataVariableNames=["et","Fz"],ColorBy="Fz");
![Figure contains an axes object. The axes object with title Normal force [N] vs Elapsed time [s], xlabel Elapsed time [s], ylabel Normal force [N] contains 4 objects of type line. One or more of the lines displays its values using only markers These objects represent 2140, 4270, 5160, 6460.](../../examples/vdynblks/win64/ApplyDigitalFilterImportedTireDataExample_01.png)
Specify Moving Mean
Use a moving mean to filter the data channel Fz. Set k=10.
tdFilter = filter(td,channels="Fz",k=10);Plot the resulting tireData objects in tdFilter to visualize the modified data set.
plot(tdFilter,DataVariableNames=["et","Fz"],ColorBy="Fz");
![Figure contains an axes object. The axes object with title Normal force [N] vs Elapsed time [s], xlabel Elapsed time [s], ylabel Normal force [N] contains 4 objects of type line. One or more of the lines displays its values using only markers These objects represent 2140, 4270, 5160, 6460.](../../examples/vdynblks/win64/ApplyDigitalFilterImportedTireDataExample_02.png)
Specify digitalFilter Object
Use the designfilt (Signal Processing Toolbox) function to create the digitalFilter object for a second-order IIR low-pass filter with HalfPowerFrequency=0.1.
d = designfilt("lowpassiir",FilterOrder=2,HalfPowerFrequency=0.1);Filter the data channel Fz using the digitalFilter object d.
tdFilter = filter(td,channels="Fz",d=d);Plot the resulting tireData objects in tdFilter to visualize the modified data set.
plot(tdFilter,DataVariableNames=["et","Fz"],ColorBy="Fz")
![Figure contains an axes object. The axes object with title Normal force [N] vs Elapsed time [s], xlabel Elapsed time [s], ylabel Normal force [N] contains 4 objects of type line. One or more of the lines displays its values using only markers These objects represent 2140, 4270, 5160, 6460.](../../examples/vdynblks/win64/ApplyDigitalFilterImportedTireDataExample_03.png)
Specify Transfer Function Coefficients
Generate the b and a transfer coefficients using the butter (Signal Processing Toolbox) function.
You can use additional filter design functions can be used to generate the transfer function coefficients. For more information, see FIR Filter Design (Signal Processing Toolbox).
[b,a] = butter(2,0.1,"low");Use the generated transfer coefficients to filter the data channel Fz.
tdFilter = filter(td,channels="Fz",b=b,a=a);Plot the resulting tireData objects in tdFilter to visualize the modified data set.
plot(tdFilter,DataVariableNames=["et","Fz"],ColorBy="Fz")
![Figure contains an axes object. The axes object with title Normal force [N] vs Elapsed time [s], xlabel Elapsed time [s], ylabel Normal force [N] contains 4 objects of type line. One or more of the lines displays its values using only markers These objects represent 2140, 4270, 5160, 6460.](../../examples/vdynblks/win64/ApplyDigitalFilterImportedTireDataExample_04.png)
Specify Cutoff Frequency
Set the cutoff frequency (Hz) to F=2 to use a low pass filter to filter the data channel Fz.
tdFilter = filter(td,channels="Fz",F=2);Plot the resulting tireData objects in tdFilter to visualize the modified data set.
plot(tdFilter,DataVariableNames=["et","Fz"],ColorBy="Fz")
![Figure contains an axes object. The axes object with title Normal force [N] vs Elapsed time [s], xlabel Elapsed time [s], ylabel Normal force [N] contains 4 objects of type line. One or more of the lines displays its values using only markers These objects represent 2140, 4270, 5160, 6460.](../../examples/vdynblks/win64/ApplyDigitalFilterImportedTireDataExample_05.png)
The cutoff frequency name-value argument uses the data channel et to calculate the sampling frequency. If et is empty or invalid for calculating the sampling frequency, additionally provide the sampling frequency Fs.
tdFilter = filter(td,channels="Fz",F=2,Fs=32);Plot the resulting tireData objects in tdFilter to visualize the modified data set.
plot(tdFilter,DataVariableNames=["et","Fz"],ColorBy="Fz")
![Figure contains an axes object. The axes object with title Normal force [N] vs Elapsed time [s], xlabel Elapsed time [s], ylabel Normal force [N] contains 4 objects of type line. One or more of the lines displays its values using only markers These objects represent 2140, 4270, 5160, 6460.](../../examples/vdynblks/win64/ApplyDigitalFilterImportedTireDataExample_06.png)
Input Arguments
Tire data, specified a tireData object or an array of
              tireData objects.
Name-Value Arguments
Specify optional pairs of arguments as
      Name1=Value1,...,NameN=ValueN, where Name is
      the argument name and Value is the corresponding value.
      Name-value arguments must appear after other arguments, but the order of the
      pairs does not matter.
    
Example: tdFilter = filter(td,channels="Fz",k=10);
Tire data channels to filter, specified as a vector of string scalars. String
              values must be a property of the tireData object. See tireData Properties.
Note
If you do not specify channels, then the
                    filter function filters all non-time channels.
Example: channels=["Fx", "Fy"]
Data Types: string
Window length for movmean, specified as a real positive scalar.
              The movmean function is invoked by the filter
              function when k is specified and returns the k-point mean values.
              For more information, see movmean.
Example: k=10
Data Types: double
Digital filter, specified as a digitalFilter object. Use
                designfilt to generate a digital filter based on
              frequency-response specifications. For more information, see designfilt (Signal Processing Toolbox).
Transfer function coefficients, specified as vectors.
Example: b=[0.0201 0.0402 0.0201] and a=[1 -1.5610
              0.6414]
Data Types: double
Cutoff frequency, specified as a scalar, in Hz.
Note
If the tireData channel et is empty or
                  invalid for calculating the sampling frequency, then you must provide the sampling
                  frequency Fs.
Data Types: double
Sampling frequency, specified as a scalar, in Hz.
Note
You must provide F when specifying
                    Fs, and you must specify Fs if the
                    tireData channel et is empty or invalid
                  for calculating the sampling frequency. If Fs is provided and
                  does not match et, then the filter
                  function uses the value of Fs for the filter design.
Data Types: double
Output Arguments
Filtered tire data, returned as a tireData object or vector of
              tireData objects.
Version History
Introduced in R2024a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)