filter
Description
This function requires Extended Tire Features for Vehicle Dynamics Blockset.
applies a filter specified by one or more name-value arguments to the
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
Apply Filter to Imported Tire Data
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, wherek
is the window length for local k-point mean valuesd
—digitalFilter
objectb
,a
— Transfer function coefficientsF
,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");
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");
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")
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")
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")
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")
Input Arguments
obj
— Tire data
tireData
object | array of tireData
objects
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);
channels
— Tire data channels to filter
vector of string scalars
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
k
— Window length for movmean
real positive scalar
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
d
— Digital filter
digitalFilter
object
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).
b,a
— Transfer function coefficients
vectors
Transfer function coefficients, specified as vectors.
Example: b=[0.0201 0.0402 0.0201] and a=[1 -1.5610
0.6414]
Data Types: double
F
— Cutoff frequency
scalar
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
Fs
— Sampling frequency
scalar
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
obj
— Filtered tire data
tireData
object | vector of tireData
objects
Filtered tire data, returned as a tireData
object or vector of
tireData
objects.
Version History
Introduced in R2024a
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)