MATLAB Code
clc;
clear all; close all;
Data_sym = [0 1 1 0 1 0 0 1];
M = 4;
Phase = 0;
Sampling_rate = 48e3;
Data_Rate = 100;
Bandwidth = 400;
Upsampling_factor = Sampling_rate/Data_Rate;
Rolloff = 0.4;
Upsampled_Data = upsample(pskmod(Data_sym,M,Phase),Upsampling_factor);
Pulse_shape = firrcos(2*Upsampling_factor,Bandwidth/2,Rolloff,Sampling_rate,'rolloff','sqrt');
Output
What if we change the roll-off
roll-off = 0.01
roll-off = 0.99
What if we change the bandwidth
Bandwidth = 100 Hz
Bandwidth = 1000 Hz
What if we change the sampling rate
Sampling rate = 10 KHz
Sampling rate = 100 KHz
Another MATLAB Code
% The code is developed by SalimWireless.Com
clc;
clear;
close all;
% Parameters
fs = 1000; % Sampling frequency in Hz
symbolRate = 100; % Symbol rate (baud)
span = 6; % Filter span in symbols
alpha = 0.25; % Roll-off factor for raised cosine filter
% Generate random data symbols
numSymbols = 100; % Number of symbols
data = randi([0 1], numSymbols, 1) * 2 - 1; % Generate random binary data (BPSK symbols: -1, 1)
% Upsample the data to match sampling rate
samplesPerSymbol = fs / symbolRate; % Samples per symbol based on fs and symbol rate
dataUpsampled = upsample(data, samplesPerSymbol);
% Create a raised cosine filter
rcFilter = rcosdesign(alpha, span, samplesPerSymbol, 'sqrt'); % Square root raised cosine filter
% Apply the filter to the upsampled data
txSignal = conv(dataUpsampled, rcFilter, 'same');
figure;
subplot(4,1,1)
stem(data);
title('Original Message signal');
grid on;
subplot(4,1,2)
plot(dataUpsampled);
title('Upsampled Message signal');
grid on;
subplot(4,1,3)
plot(rcFilter);
title('Raise Cosine Filter Coefficient');
grid on;
subplot(4,1,4)
plot(txSignal);
title('Transmitted Signal after Raised Cosine Filtering');
grid on;
clc;
clear;
close all;
% Parameters
fs = 1000; % Sampling frequency in Hz
symbolRate = 100; % Symbol rate (baud)
span = 6; % Filter span in symbols
alpha = 0.25; % Roll-off factor for raised cosine filter
% Generate random data symbols
numSymbols = 100; % Number of symbols
data = randi([0 1], numSymbols, 1) * 2 - 1; % Generate random binary data (BPSK symbols: -1, 1)
% Upsample the data to match sampling rate
samplesPerSymbol = fs / symbolRate; % Samples per symbol based on fs and symbol rate
dataUpsampled = upsample(data, samplesPerSymbol);
% Create a raised cosine filter
rcFilter = rcosdesign(alpha, span, samplesPerSymbol, 'sqrt'); % Square root raised cosine filter
% Apply the filter to the upsampled data
txSignal = conv(dataUpsampled, rcFilter, 'same');
figure;
subplot(4,1,1)
stem(data);
title('Original Message signal');
grid on;
subplot(4,1,2)
plot(dataUpsampled);
title('Upsampled Message signal');
grid on;
subplot(4,1,3)
plot(rcFilter);
title('Raise Cosine Filter Coefficient');
grid on;
subplot(4,1,4)
plot(txSignal);
title('Transmitted Signal after Raised Cosine Filtering');
grid on;
Output
Copy the MATLAB Code above from here
Raised Cosine Filter Online Simulator
Random Bits
↓
BPSK Mapping (±1)
↓
Upsampling
↓
RRC (Root Raised Cosine) Filter Pulse Shaping
Lower β values use less bandwidth but pulses are narrower in time and more susceptible to inter-symbol interference (ISI). Higher β values spread the pulse in time but reduce ISI and require more bandwidth.
Raised Cosine Filter: Basics, Formula, etc.
In wireless communication, Raised Cosine Filters (RCF) are essential for pulse shaping. Their primary goal is to minimize Inter-Symbol Interference (ISI) by ensuring the transmitted waveform fits within a specific bandwidth while maintaining timing accuracy at the receiver.
Key Formula & Bandwidth Calculation
The bandwidth ($B$) of a raised cosine filter is determined by the symbol rate ($R_s$) and the roll-off factor ($\alpha$), which ranges from 0 to 1:
Bandwidth (B) = [Symbol Rate × (1 + α)] / 2
Example: For a symbol rate of 100 symbols/sec and a roll-off factor ($\alpha$) of 0.25:
B = [100 × (1 + 0.25)] / 2 = 62.5 Hz.
This slightly exceeds the theoretical Nyquist minimum (50 Hz) to allow for realistic filter implementation without ISI.
Applications in Modern Systems
- Time-Bandwidth Product (TBP): RCFs help manage the trade-off between time localization and spectral efficiency. Higher $\alpha$ reduces ISI but increases the TBP.
- OFDM Systems: Pulse shaping confines the spectral bandwidth of OFDM waveforms, reducing out-of-band emissions and adjacent channel interference.
- Pulse Shaping: Essential for mapping digital bits to analog waveforms suitable for band-limited channels.





