%% Pass a Signal through a Raised Cosine Filter
% This example shows how to pass a signal through a square-root, raised cosine filter.
% Specify the filter parameters.

rolloff = 0.25;     % Rolloff factor
span = 6;           % Filter span in symbols
sps = 4;            % Samples per symbol

%
% Generate the square-root, raised cosine filter coefficients.

b = rcosdesign(rolloff, span, sps);

%
% Create a vector of bipolar data.

d = 2*randi([0 1], 100, 1) - 1;

%
% Upsample and filter the data for pulse shaping.

x = upfirdn(d, b, sps);

%
% Add noise.

r = x + randn(size(x))*0.01;

%
% Filter and downsample the received signal for matched filtering.

y = upfirdn(r, b, 1, sps);

% For information on how to use square-root, raised cosine filters to interpolate and decimate signals, see Interpolate and Decimate Using RRC Filter.
% Copyright 2015 The MathWorks, Inc.