X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=txFilter.m;h=10c387d627fca406299162b9bcc7189a5bfe37f9;hb=d9a5ae9d4e5369f11357d1f5825acc379fbe7e52;hp=507ffe19ef62fd8f299414004dee5a5dc5c5844d;hpb=601f851007c30d9497faa0c3aec58d33be2b9fa4;p=4yp.git diff --git a/txFilter.m b/txFilter.m index 507ffe1..10c387d 100644 --- a/txFilter.m +++ b/txFilter.m @@ -8,11 +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, ... 'Gain', sqrt(sps)); % so that output has energy 1 - x = filter([modData; zeros(span, 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