| 1 | function r = rxFilter(y, rolloff, span, sps) |
| 2 | %% Receiver matched (root raised cosine) filter, |
| 3 | %% downsampling to 2 samples/sym. |
| 4 | %% Inputs: |
| 5 | %% - y: received waveform |
| 6 | %% - rolloff: rolloff factor in root raised cosine filter |
| 7 | %% - span: filter span (number of symbols) |
| 8 | %% - sps: Input samples per symbol |
| 9 | %% Output: |
| 10 | %% - r: filtered signal |
| 11 | |
| 12 | %% Construct filter object |
| 13 | rxfilter = comm.RaisedCosineReceiveFilter... |
| 14 | ('Shape', 'Square root', ... |
| 15 | 'RolloffFactor', rolloff, ... |
| 16 | 'FilterSpanInSymbols', span, ... |
| 17 | 'InputSamplesPerSymbol', sps, ... |
| 18 | 'Gain', 1 / sqrt(sps)); |
| 19 | |
| 20 | %% Perform filtering in frequency domain |
| 21 | coef = coeffs(rxfilter); |
| 22 | filter_fft = fft(coef.Numerator, length(y)); |
| 23 | y_fft = fft(y); |
| 24 | rs = ifft(y_fft .* filter_fft.'); |
| 25 | |
| 26 | %% Re-order signal due to circular convolution |
| 27 | l = (length(coef.Numerator) - 1) / 2; |
| 28 | rr = [rs(l:end); rs(1:l-1)]; |
| 29 | |
| 30 | %% Downsample |
| 31 | r = downsample(rr, sps/2, 2); |
| 32 | end |