You are here : matlab → Signal Processing → rcosdesign
# rcosdesign() - Signal Processing

### Syntax

### Example

### Output / Return Value

### Limitations

### Alternatives / See Also

### Reference

exampleb = rcosdesign(beta,span,sps) returns the coefficients, b, that correspond to a square-root raised cosine FIR filter with rolloff factor specified by beta. The filter is truncated to span symbols, and each symbol period contains sps samples. The order of the filter, sps*span, must be even. The filter energy is 1. exampleb = rcosdesign(beta,span,sps,shape) returns a square-root raised cosine filter when you set shape to 'sqrt' and a normal raised cosine FIR filter when you set shape to 'normal'.

b = rcosdesign(beta,span,sps) exampleb = rcosdesign(beta,span,sps,shape) example

Design a Square-Root Raised Cosine FilterOpen This Example Specify a rolloff factor of 0.25. Truncate the filter to 6 symbols and represent each symbol with 4 samples. Verify that 'sqrt' is the default value of the shape parameter. h = rcosdesign(0.25,6,4); mx = max(abs(h-rcosdesign(0.25,6,4,'sqrt'))) fvtool(h,'Analysis','impulse') mx = 0 Impulse Responses of Normal and Square-Root Raised Cosine FiltersOpen This Example Compare a normal raised cosine filter with a square-root cosine filter. An ideal (infinite-length) normal raised cosine pulse-shaping filter is equivalent to two ideal square-root raised cosine filters in cascade. Thus, the impulse response of an FIR normal filter should resemble that of a square-root filter convolved with itself. Create a normal raised cosine filter with rolloff 0.25. Specify that this filter span 4 symbols with 3 samples per symbol.rf = 0.25; span = 4; sps = 3; h1 = rcosdesign(rf,span,sps,'normal'); fvtool(h1,'impulse') The normal filter has zero crossings at integer multiples of sps. It thus satisfies Nyquist's criterion for zero intersymbol interference. The square-root filter, however, does not:h2 = rcosdesign(rf,span,sps,'sqrt'); fvtool(h2,'impulse') Convolve the square-root filter with itself. Truncate the impulse response outward from the maximum so it has the same length as h1. Normalize the response using the maximum. Then, compare the convolved square-root filter to the normal filter.h3 = conv(h2,h2); p2 = ceil(length(h3)/2); m2 = ceil(p2-length(h1)/2); M2 = floor(p2+length(h1)/2); ct = h3(m2:M2); stem([h1/max(abs(h1));ct/max(abs(ct))]','filled') xlabel('Samples') ylabel('Normalized amplitude') legend('h1','h2 * h2') The convolved response does not coincide with the normal filter because of its finite length. Increase span to obtain closer agreement between the responses and better compliance with the Nyquist criterion.Pass a Signal through a Raised Cosine FilterOpen This Example This example shows how to pass a signal through a square-root, raised cosine filter. Specify the filter parameters.rolloff = 0.25; % Rolloff factor span = 6; % Filter span in symbols sps = 4; % Samples per symbol Generate the square-root, raised cosine filter coefficients.b = rcosdesign(rolloff, span, sps); Create a vector of bipolar data.d = 2*randi([0 1], 100, 1) - 1; Upsample and filter the data for pulse shaping.x = upfirdn(d, b, sps); Add noise.r = x + randn(size(x))*0.01; Filter and downsample the received signal for matched filtering.y = upfirdn(r, b, 1, sps); Interpolate and Decimate Using RRC FilterOpen This Example This example shows how to interpolate and decimate signals using square-root, raised cosine filters designed with the rcosdesign function. This example requires the Communications System Toolbox software. Define the square-root raised cosine filter parameters. Define the signal constellation parameters.rolloff = 0.25; % Filter rolloff span = 6; % Filter span sps = 4; % Samples per symbol M = 4; % Size of the signal constellation k = log2(M); % Number of bits per symbol Generate the coefficients of the square-root raised cosine filter using the rcosdesign function.rrcFilter = rcosdesign(rolloff, span, sps); Generate 10000 data symbols using the randi function.data = randi([0 M-1], 10000, 1); Apply PSK modulation to the data symbols. Because the constellation size is 4, the modulation type is QPSK.modData = pskmod(data, M, pi/4); Using the upfirdn function, upsample and filter the input data.txSig = upfirdn(modData, rrcFilter, sps); Convert the Eb/No to SNR and then pass the signal through an AWGN channel.EbNo = 7; snr = EbNo + 10*log10(k) - 10*log10(sps); rxSig = txSig + awgn(txSig, snr, 'measured'); Filter and downsample the received signal. Remove a portion of the signal to account for the filter delay.rxFilt = upfirdn(rxSig, rrcFilter, 1, sps); rxFilt = rxFilt(span+1:end-span); Create a scatterplot of the modulated data using the first 5000 symbols.h = scatterplot(sqrt(sps)* ... rxSig(1:sps*5000),... sps,0,'g.'); hold on; scatterplot(rxFilt(1:5000),1,0,'kx',h); title('Received Signal, Before and After Filtering'); legend('Before Filtering','After Filtering'); axis([-3 3 -3 3]); % Set axis ranges hold off;