You are on page 1of 9

Raised cosine filter specifications

Nsym = 6; % Filter span in symbol durations


beta = 0.5; % Roll-off factor
sampsPerSym = 8; % Upsampling factor
rctFilt = comm.RaisedCosineTransmitFilter(...
'Shape','Normal', ...
'RolloffFactor',beta, ...
'FilterSpanInSymbols',Nsym, ...
'OutputSamplesPerSymbol',sampsPerSym)
% Visualize the impulse response
fvtool(rctFilt,'Analysis','impulse')
% Normalize to obtain maximum filter tap value of 1
b = coeffs(rctFilt);
rctFilt.Gain = 1/max(b.Numerator);
% Visualize the impulse response
fvtool(rctFilt,'Analysis','impulse')

Pulse shaping with raised cosine filters


% Parameters
DataL = 20; % Data length in symbols
R = 1000; % Data rate
Fs = R * sampsPerSym; % Sampling frequency
% Create a local random stream to be used by random number generators for
% repeatability
hStr = RandStream('mt19937ar','Seed',0);
% Generate random data
x = 2*randi(hStr,[0 1],DataL,1)-1;
% Time vector sampled at symbol rate in milliseconds
tx = 1000 * (0: DataL - 1) / R;
% Filter
yo = rctFilt([x; zeros(Nsym/2,1)]);
% Time vector sampled at sampling frequency in milliseconds
to = 1000 * (0: (DataL+Nsym/2)*sampsPerSym - 1) / Fs;
% Plot data
fig1 = figure;
stem(tx, x, 'kx'); hold on;
% Plot filtered data
plot(to, yo, 'b-'); hold off;
% Set axes and labels
axis([0 30 -1.7 1.7]); xlabel('Time (ms)'); ylabel('Amplitude');
legend('Transmitted Data','Upsampled Data','Location','southeast')
% Filter group delay, since raised cosine filter is linear phase and
% symmetric.
fltDelay = Nsym / (2*R);
% Correct for propagation delay by removing filter transients
yo = yo(fltDelay*Fs+1:end);
to = 1000 * (0: DataL*sampsPerSym - 1) / Fs;
% Plot data.
stem(tx, x, 'kx'); hold on;
% Plot filtered data.
plot(to, yo, 'b-'); hold off;
% Set axes and labels.
axis([0 25 -1.7 1.7]); xlabel('Time (ms)'); ylabel('Amplitude');
legend('Transmitted Data','Upsampled Data','Location','southeast')

Roll-off factor
% Set roll-off factor to 0.2
rctFilt2 = comm.RaisedCosineTransmitFilter(...
'Shape', 'Normal', ...
'RolloffFactor', 0.2, ...
'FilterSpanInSymbols', Nsym, ...
'OutputSamplesPerSymbol', sampsPerSym);
% Normalize filter
b = coeffs(rctFilt2);
rctFilt2.Gain = 1/max(b.Numerator);
% Filter
yo1 = rctFilt2([x; zeros(Nsym/2,1)]);
% Correct for propagation delay by removing filter transients
yo1 = yo1(fltDelay*Fs+1:end);
% Plot data
stem(tx, x, 'kx'); hold on;
% Plot filtered data
plot(to, yo, 'b-',to, yo1, 'r-'); hold off;
% Set axes and labels
axis([0 25 -2 2]); xlabel('Time (ms)'); ylabel('Amplitude');
legend('Transmitted Data','beta = 0.5','beta = 0.2',...
'Location','southeast')

Square-root raised cosine filters


% Design raised cosine filter with given order in symbols
rctFilt3 = comm.RaisedCosineTransmitFilter(...
'Shape', 'Square root', ...
'RolloffFactor', beta, ...
'FilterSpanInSymbols', Nsym, ...
'OutputSamplesPerSymbol', sampsPerSym);
% Upsample and filter.
yc = rctFilt3([x; zeros(Nsym/2,1)]);
% Correct for propagation delay by removing filter transients
yc = yc(fltDelay*Fs+1:end);
% Plot data.
stem(tx, x, 'kx'); hold on;
% Plot filtered data.
plot(to, yc, 'm-'); hold off;
% Set axes and labels.
axis([0 25 -1.7 1.7]); xlabel('Time (ms)'); ylabel('Amplitude');
legend('Transmitted Data','Sqrt. Raised Cosine','Location','southeast')
% Design and normalize filter.
rcrFilt = comm.RaisedCosineReceiveFilter(...
'Shape', 'Square root', ...
'RolloffFactor', beta, ...
'FilterSpanInSymbols', Nsym, ...
'InputSamplesPerSymbol', sampsPerSym, ...
'DecimationFactor', 1);
% Filter at the receiver.
yr = rcrFilt([yc; zeros(Nsym*sampsPerSym/2, 1)]);
% Correct for propagation delay by removing filter transients
yr = yr(fltDelay*Fs+1:end);
% Plot data.
stem(tx, x, 'kx'); hold on;
% Plot filtered data.
plot(to, yr, 'b-',to, yo, 'm:'); hold off;
% Set axes and labels.
axis([0 25 -1.7 1.7]); xlabel('Time (ms)'); ylabel('Amplitude');
legend('Transmitted Data','Rcv Filter Output', ...
'Raised Cosine Filter Output','Location','southeast')

Computational cost
C1 = cost(rctFilt3);
C2 = cost(rcrFilt);

Outputs obtained
rctFilt = comm.RaisedCosineTransmitFilter with properties:
Shape: 'Normal'
RolloffFactor: 0.5000
FilterSpanInSymbols: 6
OutputSamplesPerSymbol: 8
Gain: 1

Raised cosine filter specifications


Pulse shaping with raised cosine filters
Roll-off factor
Square-root raised cosine filters
Computational cost
------------------------------------------------------------------------
Implementation Cost Comparison
------------------------------------------------------------------------
Multipliers Adders Mult/Symbol Add/Symbol
Multirate Interpolator 49 41 49 41
Multirate Decimator 49 48 6.125 6

You might also like