X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=txFilter.m;h=10c387d627fca406299162b9bcc7189a5bfe37f9;hb=d9a5ae9d4e5369f11357d1f5825acc379fbe7e52;hp=49164d37f0c1ae811f8b29fd92c2d4a025da80a8;hpb=1eeb62fbc496ed5c170d199143ad53e28122d29c;p=4yp.git diff --git a/txFilter.m b/txFilter.m index 49164d3..10c387d 100644 --- a/txFilter.m +++ b/txFilter.m @@ -8,10 +8,17 @@ function x = txFilter(modData, rolloff, span, sps) %% Output: %% - x: pulse-shaped waveform - filter = comm.RaisedCosineTransmitFilter... + txfilter = comm.RaisedCosineTransmitFilter... ('Shape', 'Square root', ... 'RolloffFactor', rolloff, ... 'FilterSpanInSymbols', span, ... - 'OutputSamplesPerSymbol', sps); - x = filter([modData; zeros(span, 1)]); + 'OutputSamplesPerSymbol', sps, ... + 'Gain', sqrt(sps)); % so that output has energy 1 + + coef = coeffs(txfilter); + filter_fft = fft(coef.Numerator, length(modData) * sps); + modData_fft = fft(upsample(modData, sps)); + x = ifft(modData_fft .* filter_fft.'); + l = (length(coef.Numerator) - 1) / 2; + x = [x(l:end); x(1:l-1)]; end