Vous êtes sur la page 1sur 28

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Creative Commons
% Attribution-Noncommercial 2.5 India
% You are free:
% to Share to copy, distribute and transmit the work
% to Remix to adapt the work
% Under the following conditions:
% Attribution. You must attribute the work in the manner
% specified by the author or licensor (but not in any way
% that suggests that they endorse you or your use of the work).
% Noncommercial. You may not use this work for commercial purposes.
% For any reuse or distribution, you must make clear to others the
% license terms of this work. The best way to do this is with a
% link to this web page.
% Any of the above conditions can be waived if you get permission
% from the copyright holder.
% Nothing in this license impairs or restricts the author's moral rights.
% http://creativecommons.org/licenses/by-nc/2.5/in/
%
%
%
%
%
%
%
%
%

Checked for proper operation with Octave Version 3.0.0


Author
: Krishna
Email
: krishna@dsplog.com
Version
: 1.1
Date
: 25 May 2008
Details
: Corrected the
Version
: 1.0
Date
: 30 April 2008
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Script for plotting the eye diagram where transmit filtering


% is performed by raised cosine filtering with alpha=0.5, alpha=1.
clear
N = 10^3; % number of symbols
am = 2*(rand(1,N)>0.5)-1 + j*(2*(rand(1,N)>0.5)-1); % generating random
binary sequence
fs = 10; % sampling frequency in Hz
% defining the sinc filter
sincNum = sin(pi*[-fs:1/fs:fs]); % numerator of the sinc function
sincDen = (pi*[-fs:1/fs:fs]); % denominator of the sinc function
sincDenZero = find(abs(sincDen) < 10^-10);
sincOp = sincNum./sincDen;
sincOp(sincDenZero) = 1; % sin(pix/(pix) =1 for x =0
% raised cosine filter
alpha = 0.5;
cosNum = cos(alpha*pi*[-fs:1/fs:fs]);
cosDen = (1-(2*alpha*[-fs:1/fs:fs]).^2);
cosDenZero = find(abs(cosDen)<10^-10);
cosOp = cosNum./cosDen;
cosOp(cosDenZero) = pi/4;
gt_alpha5 = sincOp.*cosOp;
alpha = 1;
cosNum = cos(alpha*pi*[-fs:1/fs:fs]);
cosDen = (1-(2*alpha*[-fs:1/fs:fs]).^2);
cosDenZero = find(abs(cosDen)<10^-10);
cosOp = cosNum./cosDen;
cosOp(cosDenZero) = pi/4;

gt_alpha1 = sincOp.*cosOp;
% upsampling the transmit sequence
amUpSampled = [am;zeros(fs-1,length(am))];
amU = amUpSampled(:)';
% filtered sequence
st_alpha5 = conv(amU,gt_alpha5);
st_alpha1 = conv(amU,gt_alpha1);
% taking only the first 10000 samples
st_alpha5 = st_alpha5([1:10000]);
st_alpha1 = st_alpha1([1:10000]);
st_alpha5_reshape = reshape(st_alpha5,fs*2,N*fs/20).';
st_alpha1_reshape = reshape(st_alpha1,fs*2,N*fs/20).';
close all
figure;
plot([0:1/fs:1.99],real(st_alpha5_reshape).','b');
title('eye diagram with alpha=0.5');
xlabel('time')
ylabel('amplitude')
axis([0 2 -1.5 1.5])
grid on
figure;
plot([0:1/fs:1.99],real(st_alpha1_reshape).','b');
title('eye diagram with alpha=1')
xlabel('time')
ylabel('amplitude')
axis([0 2 -1.5 1.5 ])
grid on

Fahmi November 3, 2009 at 8:55 pm


Hi Mr krishna ,
I dont understand the utility of upsampling the transmit sequence
what will happen if we did not add the zeros to the sequence ?
I wonder if there is some links clarifying this idea .
thank you very much.

@Fahmi: With a sampling frequency of fs, we can see frequencies from [-fs/2 to fs/2).
Typically, we would want to control a bigger bandwidth compared to the original transmit
sequence. Hence we do upsampling

Interpolation filter design


Let X(f) be the Fourier transform of any function, x(t), whose samples at some interval, T, equal
the x[n] sequence. Then the discrete-time Fourier transform(DTFT) of the x[n] sequence is
the Fourier series representation of a periodic summation of X(f):

(Eq.1)

When T has units of seconds,

has units of hertz. Sampling L times faster (at interval T/L)

increases the periodicity by a factor of L:


(Eq.
2)
which is also the desired result of interpolation. An example of both these distributions is
depicted in the top two graphs of Fig.1.

Fig 1: Spectral depictions of zero-fill and interpolation by lowpass filtering

When the additional samples are inserted zeros, they increase the data rate, but they
have no effect on the frequency distribution until the zeros are replaced by the
interpolation filter. Many filter design programs use frequency units ofcycles/sample,
which is achieved by normalizing the frequency axis, based on the new data rate (L/T).
The result is shown in the third graph of Fig.1. Also shown is the passband of the
interpolation filter needed to make the third graph resemble the second one. Its cutoff
frequency is

[note 1]

In terms of actual frequency, the cutoff is

Hz, which is

the Nyquist frequency of the original x[n] sequence.


The same result can be obtained from Z-transforms, constrained to values of complexvariable, z, of the form

Then the transform is the same Fourier series with

different frequency normalization. By comparison withEq.1, we deduce:

which is depicted by the fourth graph in Fig.1. When the zeros are inserted, the
transform becomes:

depicted by the bottom graph. In these normalizations, the effective data-rate is


always represented by the constant 2 (radians/sample) instead of 1. In those
units, the interpolation filter bandwidth is /L, as show on the bottom graph. The
corresponding physical frequency is

Hz, the original Nyquist

frequency.

Why oversample data before using raised cosine filter?15 Of The


In the process of creating a baseband signal, the complex symbols are filtered using a raised
cosine filter to perform pulse shaping (I'm following some literature as a guide). The pulse
shaping is performed with the code:
%Create the filter
over=16;
pulse=rcosine(1,over,'normal',0.35);
[trash, pos]=max(pulse);
%Oversample the symbols
sig=kron(sym,[1 zeros(1,over-1)]);
sig=filter(pulse,1,sig);
sig=sig(pos:end);

So the sampling frequency of the filter is 16, which requires 15 zeros be added between all of
the symbols. What is the purpose of this? How does this not introduce "extra data" into the
original message?

In digital communications, you can transmit a sequence of numbers using a train of pulses that
don't interfere with each other. A given raised cosine pulse p(t) has zero crossings
every T seconds around its peak (for a certain T). Let's say you want to transmit the number
sequence {3,5}. You can do this with the 2-pulse train

s(t)=3p(t)5p(tT).

If you sample s(t) at t=0 and t=T, you'll get the values 3 and -5.
Your question is related to implementing this idea in Matlab. To do this, you have to solve two
different problems: how to create the pulse p(t), and then how to create the train pulse s(t).
Let's start with the pulse p(t). Since you specify Fd=1, then the number of samples in the
pulse between the peak and its zero-crossings is given by over. In your case, you can see that
the peak occurs at sample 49 and the first zero crossing at sample 65, or 16 samples apart,
which is the value of variable over. So, you have defined a pulse p(t) with T equal to 16
sample intervals.
In order to generate the pulse train s(t), you start with the sequence sym. Then you insert 15
zeros between the elements of sym, and finally calculate the convolution of the spaced
sequence and the pulse. The result of the convolution will be the addition of pulses p(tT),
scaled with the values of sym.
Let us return to the example of transmitting the sequence {3,5}. You start with
sym = [3 -5];

from which you generate sig:


sig = [3 0 ... 0 -5 0 ... 0];
The convolution of sig and pulse is the addition of 3*pulse starting at sample 1, and 5*pulsestarting at sample 16. The first pulse has a peak equal to 3 at sample number 49, and

the second pulse has a peak equal to -5 at sample number 65. The pulses interfere with each
other at most sample times but, crucially, the second pulse is zero at sample 50, and the first is
zero at sample 66. So, at those precise times, they don't interfere with each other. By sampling
the convolution at those times, the receiver can recover the transmitted sequence.
Try this simple code in Matlab:
p=rcosine(1,16,'normal',0.35);
s=[3,-5];
sig=kron(s,[1 zeros(1,15)]);
ss=filter(sig,1,x);
plot(ss);

Using the data cursor, you can verify what I said above. You can also print those values with:
[ss(49) ss(65)]

we were given a code about simulation of bpsk. in that code signal was upsampled. and
then during pulse shaping by root raised cosine filter, it was multiplied by squareroot of
upsampling factor as follows
x=round(rand(1,16000)); %generating random data
xk=(-1).^x; %generating BPSK symbols
x_input=upsample(xk,100);
b=sqrt(100)*firrcos(255,0.01,1,2,'rolloff','sqrt') ;
i want to know what actually is the advantage of upsampling( inserting extra zeroes
between samples) and why was firrcos multiplied by sqrt(100)?

1-

Pulse shaping filter reduce side lob level and interference to other channel
frequencies, but we have two choice for implementing Raise Cosine filter, (a)
using analog filter after D/C converter, or (b) using upsampling for practical
possibility of digital implementation.
2- sqrt(100) is because after upsampling signal power decrease 100 times and
for canceling this effect we should multiple output by sqrt(100)

2-

about upsampling you can refer to Discrete-Time Signal Processing by Allen


Oppenheim. but I'm not able to suggest any book about discrete
implementation of digital modulation, maybe the best advise is using Matlab
communication toolbox and studying well-known book Digital Communication
by Praokis (or a simpler book by Haykin).

what-when-how
In Depth Tutorials and Information

Fundamentals of Multirate Systems


!

(Alibaba)

INTRODUCTION
Digital signal processing (DSP) is an area of science and engineering that has been
rapidly developed over the past years. This rapid development is a result of
significant advances in digital computers technology and integrated circuits
fabrication (Elali, 2003; Grover & Deller, 1999; Mitra, 2001; Oppenheim & Schafer,
1999; Smith, 2002; Stein, 2000; White, 2000).
Classical digital signal processing structures belong to the class of single-rate

systems since the sampling rates at all points of the system are the same.
The process of converting a signal from a given rate to a different rate is called
sampling rate conversion. Systems that employ multiple sampling rates in the
processing of digital signals are called multirate digital signal processing systems.
Sample rate conversion is one of the main operations in a multirate system (Stearns,
2002).

BACKGROUND
Decimation
The reduction of a sampling rate is called decimation, because the original
sample set is reduced (decimated). Decimation consists of two stages: filtering
and down sampling, as shown in Figure 1. The discrete input signal is u(n) and the
signal after filtering is x(n). Both signals have the same input sampling rate fi.
Down sampling reduces the input sampling ratefiby an integer factor M, which
is known as a down sampling factor. Thus, the output discrete signal y(m) has the
sampling rate f /M. It is customary to use a box with a down-pointing arrow, followed
by a down sampling factor as a symbol to represent down sampling, as shown in
Figure 2.

Figure 1. Decimation

The output signal y(m) is called a down sampled signal and is obtained by taking only
every M-th sample of the input signal and discarding all others,

The operation of downsampling is not invertible because it requires setting some of


the samples to zero. In other words, we can not recover x(n) fromy(m) exactly, but
can only compute an approximate value.
In spectral domain downsampling introduces the repeated replicas of the
original spectrum at every 2 /M. If the original signal is not bandlimited to /M,
the replicas will overlap. This overlapping effect is called aliasing. In order to avoid
aliasing, it is necessary to limit the spectrum of the signal before downsampling to
below /M. This is why a lowpass digital filter (from Figure 1) precedes the
downsampler. This filter is called a decimation or antialiasing filter.
Three useful identities summarize the important properties associated with
downsampling (Dabrowski, 1997; Jovanovic-Dolecek, 2002). The first identity
states that the sum of the scaled, individually downsampled signals is the same as
the downsampled sum of these signals. This property follows directly from the
principle of the superposition (linearity of operation). The second identity establishes
that a delay of M samples before the downsampler is equivalent to a delay of one
sample after the downsampler, where M is the downsampling factor. The third identity
states that the filtering by the expanded filter followed by downsampling, is equivalent
to having downsampling first, followed by the filtering with the original filter, where the
expanded filter is obtained by replacing each delay of the original filter with M delays.
In the time domain, this is equivalent to inserting M-1 zeros between the consecutive
samples ofthe impulse response.

Figure 2. Downsampling

The polyphase decimation, which utilizes polyphase components of a decimation


filter, is a preferred structure for decimation, because it enables filtering to be
performed at a lower sampling rate (Crochiere & Rabiner, 1996; Diniz, da Silva &
Netto, 2002).

Interpolorization
The procedure of increasing the sampling rate is called interpolation, and it
consists of two stages: upsampling and filtering (shown in Figure 3).
The upsampler increases the sampling rate by an integer factor L, by inserting
L-1 equally spaced zeros between each pair of samples of the input signal x(n) as
shown by,where L is called interpolation factor.

As Figure 4 illustrates, the symbol for this operation is a box with an upwardpointing arrow, followed by the interpolation factor. We can notice that the input
sampling rate fi is increased L times.
The process of upsampling does not change the content of the input
signal, and it only introduces the scaling of the time axis by a factor L. Consequently,
the operation of upsampling (unlike downsampling) is invertible, or, in other words, it
is possible to recover the input signal x(m) from samples ofy(n) exactly.
The process of upsampling introduces the replicas of the main spectra at every
2 /L. This is called imaging, since there are L-1 replicas (images) in 2 . In order to
remove the unwanted image spectra, a lowpass filter must be placed immediately
after upsampling (Figure 3). This filter is called an anti-imaging filter. In the time
domain, the effect is that the zero-valued samples introduced by upsampler are filled
with interpolated values. Because of this property, the filter is also called an
interpolation filter.
We have already seen three useful identities of the downsampled signals, and
now we will state the identities associated with upsampling. The fourth identity
asserts that the output signal obtained by upsampling followed by scaling of the input
signal will give the same result as if the signal is first scaled and then upsampled.
The fifth identity states that a delay of one sample before upsampling is equivalent to
the delay of L samples after upsampling. The sixth identity, which is a more general
version of the fifth identity, states that filtering followed by upsampling is equivalent to
having upsampling first followed by expanded filtering (Dabrowski, 1997; Diniz, da
Silva & Netto, 2002; Jovanovic-Dolecek, 2002).

Figure 3. Interpolation

Cascade of Sampling Convertors


An interchange of cascaded sampling converters can often lead to a computationally
more efficient realization (Fliedge, 2000; Vaidyanathan, 1993). If upsampling
precedes downsampling, where both operations have the same factor, the signal is
not changed. However, if downsampling is performed before upsampling, and both
operations have the same factor, the resulting signal will be different from the input
signal. Rational sampling conversion, that is, changing the sampling rate by a ratio of
two integers, L/M can be efficiently performed as a cascade of upsampling and
downsampling, where the interpolation and decimation filters are combined into one
filter.

FUTURE TRENDS
Applications
Multirate systems have applications in digital radio, speech processing,
telecommunications, wavelet transform, digital filtering, A/D converters, spectrum
estimation, and so forth.
There are many applications where the signal of a given sampling rate needs to
be converted into an equivalent signal with a different sampling rate. For
example, in digital radio, three different sampling rates are used: 32 kHz in
broadcasting, 44.1 kHz in digital compact disc (CD),and 48 kHz in digital audio tape
(DAT) (Fliedge, 2000;Mitra, 2001). Conversion of the sampling rate of audio signals
between these three different rates is often necessary. For example, if we wish
to play CD music which has a rate of 44.1 kHz in a studio which operates at a 48 kHz
rate,then the CD data rate must be increased to 48 kHz using a multirate technique.

Figure 4. Interpolation

In speech processing, multirate techniques are used to reduce the storage space or
the transmission rate of speech data (Ifeachor & Jervis, 2001). In the past years,
multirate speech and audio signal processing has been a research topic that has
produced several efficient algorithms for echo and noise cancellation, active noise
cancellation, speech enhancement, and so forth (Diniz, da Silva & Netto, 2002;
Jovanovic-Dolecek, 2002; Smith, 2001).
An example of an application of multirate signal processing in
telecommunications is the translation between two multiplexing formats, time
division multiplexing (TDM) and frequency division multiplexing (FDM) (Fliedge,
2000; Harris, 2004; Smith, 2001). The filter banks are used to separate a signal into
two or more signals (analysis filter bank) or to compose two or more signals into a
single signal (synthesis filter bank). Multirate systems and filter banks have found
many applications in source and channel coding, thereby providing a bridge between
communication system design/analysis and signal processing tools (Vaidyanathan,
1993).
One of the most fascinating developments in the field of multirate signal
processing has been the establishment of its link to the discrete wavelet transform
(Diniz, da Silva, & Netto, 2002; Rao, 2002; Suter, 1998). This link has been
responsible for the rapid application of wavelets in fields such as image compression.
Multirate processing has found important application in the efficient
implementation of DSP functions (Ifeachor & Jervis, 2001). The multirate
approach increases the computational speed, decreases the overall filter order,
reduces word-length effects, decreases power consumption, making it vital for
efficient filtering. Basic multirate techniques used to satisfy the filter requirements are
the polyphase decomposition, multistage filtering and frequency masking approach.
The need for inexpensive, high resolution analog/ digital (A/D) converters has led to
the use of oversampling techniques in the design of such converters, that is, to
sample the analog signal at a rate much higher than the Nyquist rate, one uses a fast

low-resolution A/D converter, and then decimates the digital output of the converter to
the Nyquist rate. Such A/D converter relaxes the sharp cutoff requirements of the
analog anti-aliasing filter, resulting in a more efficient structure, (JovanovicDolecek,2002; Mitra, 2001).
Another application of multirate signal processing is in the area of spectrum
estimation. The computational requirements for narrowband spectrum estimation
based on discrete Fourier transform can be significantly reduced by using the
sampling rate conversion (Vaidyanathan, 1993).
It is expected that in future the applications of multirate systems will play a very
important role for resolving problems in communications, control, wavelet analysis,
analog/digital converters and so forth. From the other side, the different applications
will give an impulse to develop a new algorithms and design methods for multirate
systems.

CONCLUSION
There are many applications where the signal of a given sampling rate needs to
be converted into an equivalent signal with a different sampling rate. The main
reasons could be to increase efficiency or simply to match digital signals that have
different rates. During the past several years, the multirate processing of digital
signals has been attracted by many researchers and the utilization of multirate
techniques is becoming an indispensable tool of the electrical engineering
profession (Suter,1998).
Changing the sampling rate can reduce the computation necessary to
complete some DSP operations, and thus reduce the overall system cost.
Consequently, the main advantage of multirate systems lies in their high
computational efficiency.

KEY TERMS
Analysis Filter Bank: Decomposes the input signal into a set of subband signals
with each subband signal occupying a portion of the original frequency band.
Continuous-Time Signals: Defined along a continuum of time t and thus are
represented by continuous independent variables, for example xc(t). Continuous-time
signals are often referred to as analog signals.
Decimation: The process of decreasing the sampling rate. It consists of filtering and

downsampling.
Decimation Filter: The filter used in decimation to avoid aliasing caused by
downsampling.
Digital Filter: The filter is a discrete-time system, which changes the characteristics
of the input discrete signal in a desired manner to obtain the discrete output signal.
Digital Filter Bank: Set of digital bandpass filters with the common input or a
common output.
Discrete-Time Signals: Defined at discrete time values and thus the independent
variable has discrete values n, as for example x(n).
Interpolation: The process of increasing the sampling rate. It consists of upsampling
and filtering.
Interpolation Filter: The filter used in interpolation to remove the unwanted images
in the spectra of the upsampled signal.
Multirate System: Discrete-time systems with unequal sampling rates at various
parts of the system.
Sampling: The generation of a discrete-time signal x(n) from a continuous signal
xc(t) is called sampling, where x(n) = x(nT). T is called the sampling period and its
inverse 1/T is the sampling frequency or the sampling rate.
Subband Coding (SBC) Filter Bank: Consists of an analysis filter bank followed by
synthesis filter bank. This type of filter bank is used for partitioning signals into
subbands for coding purposes, and vice versa.
Synthesis Filter Bank: Combines subband signals into one signal.
Transmultiplexer Filter Bank (TMUX): Consists of a synthesis filter bank followed
by an analysis filter bank. This type of filter bank is used for converting timemultiplexed signals (TDM) into frequency-multiplexed signals (FDM), and vice versa.

Filtering with Raised Cosine Filters


The rcosflt function applies a raised cosine filter to data. Because rcosflt is a
versatile function, you can:
Use

rcosflt

to both design and implement the filter.

Specify a raised cosine filter and use


data.

rcosflt

only to filter the

Design and implement either raised cosine filters or squareroot raised cosine filters.
Specify the rolloff factor and/or group delay of the filter,
if rcosflt designs the filter.
Design and implement either FIR or IIR filters.
This section discusses the use of sampling rates in filtering, and then covers these
options. For additional examples, see rcosdemo.
Sampling Rates
The basic rcosflt syntax
y = rcosflt(x,Fd,Fs...) % Basic syntax

assumes by default that you want to apply the filter to a digital


signal x whose sampling rate is Fd. The filter's sampling rate is Fs. The ratio
of Fs to Fd must be an integer. By default, the function upsamples the input data by
a factor of Fs/Fd before filtering. It upsamples by inserting Fs/Fd-1 zeros between
input data samples. The upsampled data consists of Fs/Fd samples per symbol and
has sampling rate Fs.
An example using this syntax is below. The output sampling rate is four times the
input sampling rate.
y1 = rcosflt([1;0;0],1,4,'fir'); % Upsample by factor of 4/1.

Maintaining the Input Sampling Rate. You can also override the default
upsampling behavior. In this case, the function assumes that the input signal already
has sampling rate Fs and consists of Fs/Fd samples per symbol. You might want to
maintain the sampling rate in a receiver's filter if the corresponding transmitter's
filter has already upsampled sufficiently.
To maintain the sampling rate, modify the fourth input argument in rcosflt to
include the string Fs. For example, in the first command below, rcosflt uses its
default upsampling behavior and the output sampling rate is four times the input
sampling rate. By contrast, the second command below uses Fs in the string
argument and thus maintains the sampling rate throughout.
y1 = rcosflt([1;0;0],1,4,'fir'); % Upsample by factor of 4/1.
y2 = rcosflt([1;0;0],1,4,'fir/Fs'); % Maintain sampling rate.

The second command assumes that the sampling rate of the input signal is 4, and
that the input signal contains 4/1 samples per symbol.

An example that uses the 'Fs' option at the receiver is in Combining Two SquareRoot Raised Cosine Filters.
Designing Filters Automatically
The simplest syntax of rcosflt assumes that the function should both design and
implement the raised cosine filter. For example, the command below designs an
FIR raised cosine filter and then filters the input vector [1;0;0] with it. The second
and third input arguments indicate that the function should upsample the data by a
factor of 8 (that is, 8/1) during the filtering process.
y = rcosflt([1;0;0],1,8);

Types of Raised Cosine Filters. You can have rcosflt design other types of
raised cosine filters by using a fourth input argument. Variations on the previous
example are below.
y
y
y
y

=
=
=
=

rcosflt([1;0;0],1,8,'fir'); % Same as original example


rcosflt([1;0;0],1,8,'fir/sqrt'); % FIR square-root RC filter
rcosflt([1;0;0],1,8,'iir'); % IIR raised cosine filter
rcosflt([1;0;0],1,8,'iir/sqrt'); % IIR square-root RC filter

Specifying Filters Using Input Arguments


If you have a transfer function for a raised cosine filter, then you can provide it as
an input to rcosflt so that rcosflt does not design its own filter. This is useful if
you want to use rcosine to design the filter once and then use the filter many times.
For example, the rcosflt command below uses the 'filter' flag to indicate that
transfer function is an input argument. The input num is a vector that represents the
FIR transfer function by listing its coefficients.
num = rcosine(1,8); y = rcosflt([1;0;0],1,8,'filter',num);

This syntax for rcosflt works whether num represents the transfer function for a
square-root raised cosine FIR filter or an ordinary raised cosine FIR filter. For
example, the code below uses a square-root raised cosine FIR filter. Only the
definition of num is different.
num = rcosine(1,8,'sqrt'); y = rcosflt([1;0;0],1,8,'filter',num);

You can also use a raised cosine IIR filter. To do this, modify the fourth input
argument of the rcosflt command above so that it contains the string 'iir' and
provide a denominator argument. An example is below.
delay = 8;
[num,den] = rcosine(1,8,'iir',.5,delay);
y = rcosflt([1;0;0],1,8,'iir/filter',num,den,delay);

Controlling the Rolloff Factor

If rcosflt designs the filter automatically, then you can control the rolloff factor of
the filter, as described below. If you specify your own filter, then rcosflt does not
need to know its rolloff factor.
The rolloff factor determines the excess bandwidth of the filter. For example, a
rolloff factor of .5 means that the bandwidth of the filter is 1.5 times the input
sampling frequency, Fd. This also means that the transition band of the filter
extends from .5 * Fd to 1.5 * Fd.
The default rolloff factor is .5, but if you want to use a value of .2, then you can use
a command such as the one below. Typical values for the rolloff factor are
between .2 and .5.
y = rcosflt([1;0;0],1,8,'fir',.2); % Rolloff factor is .2.

Controlling the Group Delay


If rcosflt designs the filter automatically, then you can control the group delay of
the filter, as described below. If you specify your own FIR filter, then rcosflt does
not need to know its group delay.
The filter's group delay is the time between the filter's initial response and its peak
response. The default group delay in the implementation is three input samples. To
specify a different value, measure it in input symbol periods and provide it as the
sixth input argument. For example, the command below specifies a group delay of
six input samples, which is equivalent to 6*8/1 output samples.
y = rcosflt([1;0;0],1,8,'fir',.2,6); % Delay is 6 input samples.

The group delay influences the size of the output, as well as the order of the filter
if rcosflt designs the filter automatically. See the reference page for rcosflt for
details that relate to the syntax you want to use.
Example: Raised Cosine Filter Delays. The code below filters a signal using two
different group delays. A larger delay results in a smaller error in the frequency
response of the filter. The plot shows how the two filtered signals differ, and the
output pt indicates that the first peak occurs at different times for the two filtered
signals.
[y,t] = rcosflt(ones(10,1),1,8,'fir',.5,6); % Delay = 6 samples
[y1,t1] = rcosflt(ones(10,1),1,8,'fir',.5,8); % Delay = 8 samples
plot(t,y,t1,y1,'--') % Two curves indicate the different delays.
peak = t(find(y == max(y))); % Times where first curve peaks
peak1 = t1(find(y1 == max(y1))); % Times where second curve peaks
pt = [min(peak), min(peak1)] % First peak time for both curves
pt =
14.6250

16.6250

Figure 2-8: Delays of Three Samples (Dashed) and Five Samples (Solid)
If Fs/Fd is at least 4, then a group delay value of at least 8 works well in many
cases. In the examples of this section, Fs/Fd is 8.
Combining Two Square-Root Raised Cosine Filters
If you want to split the filtering equally between the transmitter's filter and the
receiver's filter, then you can use a pair of square-root raised cosine filters. In
theory, the combination of two square-root raised cosine filters is equivalent to
a single normal raised cosine filter. However, the limited impulse response of
practical square-root raised cosine filters causes a slight difference between the
response of two successive square-root raised cosine filters and the response of one
raised cosine filter.
Using rcosine and rcosflt to Implement Square-Root Raised Cosine
Filters. One way to implement the pair of square-root raised cosine filters is to
follow these steps:

1. Use rcosine with the


cosine filter.

'sqrt'

flag to design a square-root raised

2. Use rcosflt in the transmitter section of code to upsample


and filter the data.
3. Use rcosflt in the receiver section of code to filter the
received data without upsampling it. Use the 'Fs' flag to
avoid upsampling.
An example of this approach is below. Notice that the syntaxes for rcosflt use
the 'filter' flag to indicate that you are providing the filter's transfer function as
an input.
% First approach
x = randint(100,1,2,1234); % Data
num = rcosine(1,8,'sqrt'); % Transfer function of filter
y = rcosflt(x,1,8,'filter',num); % Filter the data.
z = rcosflt(y,1,8,'Fs/filter',num); % Filter the received data
% but do not upsample it.

Using rcosflt Alone. Another way to implement the pair of square-root raised
cosine filters is to have rcosflt both design and use the square-root raised cosine
filter. This approach avoids using rcosine. The corresponding example code is
below. Notice that the syntaxes for rcosflt use the 'sqrt' flag to indicate that you
want it to design a square-root raised cosine filter.
% Second approach
x = randint(100,1,2,1234); % Data (again)
y1 = rcosflt(x,1,8,'sqrt'); % Design and use a filter.
z1 = rcosflt(y1,1,8,'sqrt/Fs'); % Design and use a filter
% but do not upsample the data.

Because these two approaches are equivalent, y is the same as y1 and z is the same
as z1.
Designing Raised Cosine Filters
The rcosine function designs (but does not apply) filters of these types:
Finite impulse response (FIR) raised cosine filter
Infinite impulse response (IIR) raised cosine filter
FIR square-root raised cosine filter
IIR square-root raised cosine filter

The function returns the transfer function as output. To learn about applying raised
cosine filters, see Filtering with Raised Cosine Filters.
Sampling Rates
The rcosine function assumes that you want to apply the filter to a digital
signal whose sampling rate is Fd. The function also requires you to provide the
filter's sampling rate, Fs. The ratio of Fsto Fd must be an integer.
Example Designing a Square-Root Raised Cosine Filter
For example, the command below designs a square-root raised cosine FIR filter
with a sampling rate of 2, for use with a digital signal whose sampling rate is 1.
num = rcosine(1,2,'fir/sqrt')
num =
Columns 1 through 7
0.0021
0.8037

-0.0106

0.0300

-0.0531

-0.0750

0.4092

-0.0531

0.0300

-0.0106

0.0021

Columns 8 through 13
0.4092

-0.0750

Here, the vector num contains the coefficients of the filter, in ascending order of
powers of z-1.
Other Options in Filter Design
You can also control the filter design by specifying the rolloff factor, group delay,
and (for IIR filters) tolerance index explicitly, instead of having rcosine use its
default values. The reference entry for rcosine explains these parameters. The
group delay is also mentioned above in Noncausality and the Group Delay
Parameter.

Vous aimerez peut-être aussi