# Design RRC filter [closed]

I have designed a RRC filter, as below :

clear all; clc;

Ts = 8.1380e-06;           %sampling rate
Nos = 24;                  %upsampling factor
alpha = 0.5;               %Rollback

t1 = [-6*Ts:Ts/Nos:-Ts/Nos];
t2 = [Ts/Nos:Ts/Nos:6*Ts];

r1 = (4*alpha/(pi*sqrt(Ts)))*(cos((1+alpha)*pi*t1/Ts)+(Ts./(4*alpha*t1)).*sin((1-alpha)*pi*t1/Ts))./(1-(4*alpha*t1/Ts).^2);
r2 = (4*alpha/(pi*sqrt(Ts)))*(cos((1+alpha)*pi*t2/Ts)+(Ts./(4*alpha*t2)).*sin((1-alpha)*pi*t2/Ts))./(1-(4*alpha*t2/Ts).^2);

r = [r1 (4*alpha/(pi*sqrt(Ts))+(1-alpha)/sqrt(Ts)) r2];


The creation of that filter is following the theoretical ways. But the problem is when I set the rollback to 0.5, the shape of filter is shown as below:

/

What's the problem of that non-defined values (NAN)?? however when I set the rollback into 0.9, it's ok

• you divide by something that can become zero, and then you evaluate there. So, you get NaN. (I'd guess you've figured that out on your own - if you didn't, you can step through Matlab programs and always figure out where the NaNs start appearing). So, what exactly is the question here? Commented Aug 18, 2020 at 9:19
• the NAN is in position 134, but I don't get something divided by zero there Commented Aug 18, 2020 at 11:42
• This is totally normal debugging (hint: everything is as expected, you're just not implementing the full formula). It's absolutely within your capabilities to figure out where that division happens :) Commented Aug 18, 2020 at 11:46

You have $$\frac{0}{0}$$ situation, similar to evaluating $$\frac{\text{sin}(x)}{x}$$ for $$x = 0$$. It's a well defined result but you can't directly compute it this way.

In your case that happens if $$\frac{t}{T_s} = \pm0.5$$ since the denominator $$\bigg(1-\big(4\alpha \frac{t_2}{T_s}\big)^2\bigg)$$ becomes 0. The numerator ALSO becomes zero and the result is well defined.

You have a few choices here

1. Isolate the zero in the denominator and calculate the result manually with pen and paper.
2. Isolate the zero and just "nudge" this x-value by a very small number. Maybe $$10^{-20}$$ or so.
3. Choose a grid for your sampling that doesn't include $$\frac{t}{T_s} = 0.5$$

The expression for an RRC filter in the time domain has 3 removable singularities. You have to take care to handle all 3 of them when generating your filter taps.

Here's some Octave (Matlab clone) code:

Fs = 20000;  % sample rate
Rs = 2000;   % symbol rate
sps = Fs/Rs; % samples per symbol

%
% Root raised cosine pulse filter
% https://www.michael-joost.de/rrcfilter.pdf
%
r = 0.5; % bandwidth factor

ntaps = 8 * sps + 1;  % filter is 8 symbols in length
st = [-floor(ntaps/2):floor(ntaps/2)] / sps;  % symbol time
hpulse = 1/sqrt(sps) * (sin ((1-r)*pi*st) + 4*r*st.*cos((1+r)*pi*st)) ./ (pi*st.*(1-(4*r*st).^2));

% fix the removable singularities
hpulse(ceil(ntaps/2)) = 1/sqrt(sps) * (1 - r + 4*r/pi); % t = 0 singulatiry
sing_idx = find(abs(1-(4*r*st).^2) < 0.000001);
for k = [1:length(sing_idx)]
hpulse(sing_idx) = 1/sqrt(sps) * r/sqrt(2) * ((1+2/pi)*sin(pi/(4*r))+(1-2/pi)*cos(pi/(4*r)));
printf('Fixed the other removable singularities\n');
end

% normalize to 0 dB gain
hpulse = hpulse / sum(hpulse);

figure(1);
plot(st, hpulse, 'x-');
xlabel("Time (symbols)");
ylabel("Amplitude");
title("RRC Filter Taps");
grid on;