# why does my FIR output contain discontinuities?

Started by December 17, 2011
```for comparison, here is an 80-tap FIR that was numerically optimized for
-40 dBc peak -in-band error and some reasonable stopband rejection. One
should have a look at the requirements for both, then reconsider the
length.

frequency response (blue), error vector magnitude (red)
http://www.dsprelated.com/blogimages/MarkusNentwig/comp.dsp/111220_RRC1.png

impulse response:
http://www.dsprelated.com/blogimages/MarkusNentwig/comp.dsp/111220_RRC1.png
http://www.dsprelated.com/blogimages/MarkusNentwig/comp.dsp/111220_ir.dat

```
```typo in the frequency response URL:
frequency response (blue), error vector magnitude (red)
http://www.dsprelated.com/blogimages/MarkusNentwig/comp.dsp/111220_RRC2.png

```
```Here is example of using firls for even filter with two equal peaks (even
symmetry).set dc gain to 1, transition band as per suitable formula, stop
band at zero.

B = .15;  %rolloff
Rs = .5;  %symbols upsampled by 2
T = 1/Rs;
Fn = Rs/2;

%transition band
f = linspace((1-B)/4,(1+B)/4,256);
for i = 1:256
A(i) = sqrt(.5 + .5*sin(pi/(2*Fn)*(Fn - f(i))/B));
end

%stopband
A(224:end) = 0;

h = firls(79,[0 f*2 1],[1 A 0],[1 ones(1,256/2-1)*1 1]);

```
```an interesting comparison.
Both are (or "should be") optimal, as they are the result of a LMS
algorithm.
The difference is in the weighting of the error that is minimized, how to

The "firls" design minimizes the error over the whole bandwidth. An in-band
vector error due to ripple is considered as "important" as out-of-band
leakage, and the sum of all errors over the whole bandwidth is minimized.

I'm putting a bit more emphasis on stopband rejection, but the numbers are
quite arbitrary.
The radio standard will demand a "spectral emission mask", and most likely
the point where the stopband start (let's say, bin 8000 in the following
pictures) will become the critical requirement that determines your filter
size, when a given error vector magnitude may not be exceeded.

stopband: blue = firls; black = "my" weighted LS design
http://www.dsprelated.com/blogimages/MarkusNentwig/comp.dsp/111220_out1.png

passband ripple
http://www.dsprelated.com/blogimages/MarkusNentwig/comp.dsp/111220_out2.png
```
```argh... I meant the other way round. It's late...
blue = "my" weighted LS design

```
```Hi all,

Regarding the 'original' question about discontinuities in the filter time
series output, the cause turned out to be as a result of truncation of the
impulse response.

As the impulse response length is decreased (by reducing N), errors appear
in the filter output every T samples

N = 256;
T = 64;
alpha = 0.5;
hd  = fdesign.pulseshaping(T,'Square Root Raised Cosine','N,Beta',N,
alpha);
h = design(hd);
figure(1);
subplot(2,1,1)
plot(-N/2:N/2,h.Numerator)
subplot(2,1,2)
y = filter(h.Numerator,1,upsample((2 * randi([0 1],1,2000))-1,T));
plot(y(N/2:100*T))

```
```Hi all,

Regarding the 'original' question about discontinuities in the filter time
series output, the cause turned out to be as a result of truncation of the
impulse response.

As the impulse response length is decreased (by reducing N), errors appear
in the filter output every T samples

N = 256;
T = 64;
alpha = 0.5;
hd  = fdesign.pulseshaping(T,'Square Root Raised Cosine','N,Beta',N,
alpha);
h = design(hd);
figure(1);
subplot(2,1,1)
plot(-N/2:N/2,h.Numerator)
subplot(2,1,2)
y = filter(h.Numerator,1,upsample((2 * randi([0 1],1,2000))-1,T));
plot(y(N/2:100*T))

```