085 7722 88897 ( Indosat ), Filter Rokok, Filter Rokok Magnet, Filter Rokok Jakarta
Anexo a Filter Matlab
Transcript of Anexo a Filter Matlab
-
8/10/2019 Anexo a Filter Matlab
1/5
filter
Filter data with filter object
Synopsis
Fixed-Point Filter Syntaxesy = filter(hd,x)
y = filter(hd,x,dim)
Adaptive Filter Syntaxy = filter(ha,x,d)
[y,e] = filter(ha,x,d)
Multirate Filter Syntaxy = filter(hm,x)
y = filter(hm,x,dim)
Description
This reference page contains three sections that describe the syntaxes for the filter objects:
Fixed-Point Filter Syntaxes
Adaptive Filter Syntaxes
Multirate Filter Syntaxes
Fixed-Point Filter Syntaxes
y = filter(hd,x)filters a vector of real or complex input data xthrough a fixed-point filter hd,
producing filtered output data y. The vectors xand yhave the same length. filter stores the final
conditions for the filter in the Statesproperty of hd
hd.states.When you set the property PersistentMemoryto false(the default setting), the initial conditions
for the filter are set to zero before filtering starts. To use nonzero initial conditions for hd,
set PersistentMemoryto true. Then sethd.statesto a vector
ofnstates(hd)elements, one element for each state to set. If you specify a scalar
forhd.states, filterexpands the scalar to a vector of the proper length for the states. All
elements of the expanded vector have the value of the scalar.
If xis a matrix, y = filter(hd,x)filters along each column of xto produce a matrix yof
independent channels. Ifxis a multidimensional array, y = filter(hd,x)filters xalong the first
nonsingleton dimension of x.
To use nonzero initial conditions when you are filtering a matrix x, set the filter states to a matrix of initial
condition values. Set the initial conditions by setting the Statesproperty for the filter (hd.states) to
a matrix of nstates(hd)rows andsize(x,2)columns.y = filter(hd,x,dim)applies the filter hdto the input data located along the specific
dimension of xspecified by dim.
When you are filtering multichannel data, dimlets you specify which dimension of the input matrix to filter
along whether a row represents a channel or a column represents a channel. When you provide
the diminput argument, the filter operates along the dimension specified by dim. When your input
data xis a vector or matrix and dimis 1, each column of xis treated as a one input channel.
When dimis 2, the filter treats each row of the input xas a channel.
To filter multichannel data in a loop environment, you must use the diminput argument to set the proper
processing dimension.
You specify the initial conditions for each channel individually, when needed, by setting hm.statesto a
matrix ofnstates(hd)rows (one row containing the states for one channel of input data)
and size(x,2)columns (one column containing the filter states for each channel).
http://www.mathworks.com/help/dsp/ref/filter.html#brygv7b-602http://www.mathworks.com/help/dsp/ref/filter.html#brygv7b-602http://www.mathworks.com/help/dsp/ref/filter.html#brygv7b-605http://www.mathworks.com/help/dsp/ref/filter.html#brygv7b-605http://www.mathworks.com/help/dsp/ref/filter.html#brygv7b-608http://www.mathworks.com/help/dsp/ref/filter.html#brygv7b-608http://www.mathworks.com/help/dsp/ref/nstates.htmlhttp://www.mathworks.com/help/dsp/ref/nstates.htmlhttp://www.mathworks.com/help/matlab/ref/size.htmlhttp://www.mathworks.com/help/matlab/ref/size.htmlhttp://www.mathworks.com/help/dsp/ref/nstates.htmlhttp://www.mathworks.com/help/dsp/ref/nstates.htmlhttp://www.mathworks.com/help/dsp/ref/nstates.htmlhttp://www.mathworks.com/help/matlab/ref/size.htmlhttp://www.mathworks.com/help/dsp/ref/nstates.htmlhttp://www.mathworks.com/help/dsp/ref/filter.html#brygv7b-608http://www.mathworks.com/help/dsp/ref/filter.html#brygv7b-605http://www.mathworks.com/help/dsp/ref/filter.html#brygv7b-602 -
8/10/2019 Anexo a Filter Matlab
2/5
Adaptive Filter Syntaxes
y = filter(ha,x,d)filters a vector of real or complex input data xthrough an adaptive filter
object ha, producing the estimated desired response data yfrom the process of adapting the filter. The
vectors xand yhave the same length. Use dfor the desired signal. Note that dand xmust be the same
length signal chains.
[y,e] = filter(ha,x,d)produces the estimated desired response data yand the prediction
error e(refer to previous syntax for more information).
Multirate Filter Syntaxes
y = filter(hm,x)filters a vector of real or complex input data xthrough a multirate filter hm,
producing filtered output data y. The length of vectors xand ydiffer by approximately the resampling
factor. filterstores the final conditions for the filter in the Statesproperty of hmhm.states.
y = filter(hm,x,dim)applies the filter hmto the input data located along the specific
dimension of xspecified by dim.
When you are filtering multichannel data, dimlets you specify which dimension of the input matrix to filter
along whether a row represents a channel or a column represents a channel. When you provide
the diminput argument, the filter operates along the dimension specified by dim. When your input
data xis a vector or matrix and dimis 1, each column of xis treated as a one input channel.
When dimis 2, the filter treats each row of the input xas a channel.To filter multichannel data in a loop environment, you must use the diminput argument to set the
processing dimension.
You specify the initial conditions for each channel individually, when needed, by setting hm.statesto a
matrix ofnstates(hm)rows (one row containing the states for one channel of input data)
and size(x,2)columns (one column containing the filter states for each channel).
The number of data samples in your input data set xdoes not need to be a multiple of the rate change
factor rfor the object. When the rate change factor is not an even divisor of the number of input
samples x, filterprocesses the samples as shown in the following figure, where the rate change
factor is 3 and the number of input samples is 23. Decimators always take the first input sample to
generate the first output sample. After that, the next output sample comes after each rnumber of input
samples.
http://www.mathworks.com/help/dsp/ref/nstates.htmlhttp://www.mathworks.com/help/dsp/ref/nstates.htmlhttp://www.mathworks.com/help/dsp/ref/nstates.html -
8/10/2019 Anexo a Filter Matlab
3/5
Examples
Filter a signal using a filter with various initial conditions (IC) or no initial conditions.
x = randn(100,1); % Original signal.
b = fir1(50,.4); % 50th-order linear-phase FIR filter.
hd = dfilt.dffir(b); % Direct-form FIR implementation.% Do not set specific initial conditions.y1 = filter(hd,x); % 'PersistentMemory'='false'(default).
zf = hd.states; % Final conditions.
Now use nonzero initial conditions by setting ICs after before you filter.
hd.persistentmemory = true;
hd.states = 1; % Uses scalar expansion.
y2 = filter(hd,x);
stem([y1 y2]) % Different sequences at beginning.
Looking at the stem plot shows that the sequences are different at the beginning of the filter process.
Here is one way to use filterwith streaming data.
reset(hd); % Clear filter history.
y3 = filter(hd,x); % Filter entire signal in one block.
As an experiment, repeat the process, filtering the data as sections, rather than in streaming form.
reset(hd); % Clear filter history.
yloop = zeros(20,5); % Preallocate output array.
xblock = reshape(x,[20 5]);
fori=1:5,
yloop(:,i) = filter(hd,xblock(:,i));end
-
8/10/2019 Anexo a Filter Matlab
4/5
Use a stem plot to see the comparison between streaming and block-by-block filtering.
stem([y3 yloop(:)]);
Filtering the signal section-by-section is equivalent to filtering the entire signal at once.
To show the similarity between filtering with discrete-time and with multirate filters, this example
demonstrates multirate filtering.
Fs = 44.1e3; % Original sampling frequency: 44.1kHz.
n = [0:10239].'; % 10240 samples, 0.232 second long signal.
x = sin(2*pi*1e3/Fs*n); % Original signal, sinusoid at 1kHz.
m = 2; % Decimation factor.
hm = mfilt.firdecim(m); % Use the default filter.
First, filter without setting initial conditions.
y1 = filter(hm,x); % PersistentMemory is false (default).
zf = hm.states; % Final conditions.
This time, set nonzero initial conditions before filtering the data.
hm.persistentmemory = true;
hm.states = 1; % Uses scalar expansion to set ICs.
y2 = filter(hm,x);
stem([y1(1:60) y2(1:60)]) % Show the filtering results.
Note the different sequences at the start of filtering.
Finally, try filtering streaming data.
reset(hm); % Clear the filter history.y3 = filter(hm,x); % Filter entire signal in one block.
-
8/10/2019 Anexo a Filter Matlab
5/5
As with the discrete-time filter, filtering the signal section by section is equivalent to filtering the entire
signal at once.
reset(hm); % Clear filter history again.
yloop = zeros(1024,5); % Preallocate output array.
xblock = reshape(x,[2048 5]);
fori=1:5,yloop(:,i) = filter(hm,xblock(:,i));
endstem([y3 yloop(:)]);
More About
collapse all
Algorithms
Quantized Filters
The filtercommand implements fixed- or floating-point arithmetic on the quantized filter structure you
specify.
The algorithm applied by filterwhen you use a discrete-time filter object on an input signal depends
on the response you chose for the filter, such as lowpass or Nyquist or bandstop. To learn more about
each filter algorithm, refer to the literature reference provided on the appropriate discrete-time fi lter
reference page.
Note dfilt/filterdoes not normalize the filter coefficients automatically. Function filtersupplied by
MATLAB does normalize the coefficients.
Adaptive Filters
The algorithm used by filterwhen you apply an adaptive filter object to a signal depends on the
algorithm you chose for your adaptive filter. To learn more about each adaptive filter algorithm, refer to the
literature reference provided on the appropriate adaptfilt.algorithmreference page.Multirate Filters
The algorithm applied by filterwhen you apply a multirate filter objects to signals depends on the
algorithm you chose for the filter the form of the multirate filter, such as decimator or interpolator. To
learn more about each filter algorithm, refer to the literature reference provided on the appropriate
multirate filter reference page.
References
[1] Oppenheim, A.V., and R.W. Schafer, Discrete-Time Signal Processing, Prentice-Hall, 1989.