Simulating a raised cosine filter

I am rewriting a simulation written in Matlab to C. I have a problem with a transmit data. The data is filtered by a raised cosine filter. In Matlab it was implemented by using the following function firrcos:

h = firrcos(20,0.25,0.25);

Does anyone know how I can find the documentation of this function ( matlab code realisation)? Does anyone have a simualtion such filter in Matlab or in C?

EDIT1

Given the order of the filter N=20, carrier frequency Fc=0,25, transition band tbW=0,25 and sampling frequency 8.

I need to initialise such filter in Simulink.

how to determine a filter span and rolloff factor knowing only the parameters above?

EDIT2

Why the filter impulse response of the filter in Simulink does look different as its implementation in Matlab?

In matlab the upper limit is 0, in Simulink it is 10

EDIT 3

How to initialise h = firrcos(20,0.25,0.25); in simulink?

MATLAB's documentation doesn't recommend the use of firrcos, instead use rcosdesign as recommend. Type doc firrcos in your command window, here are the first lines:

firrcos Raised Cosine FIR Filter design.

My guess is that firrcos is actually discontinued in new releases. To better help you, try using rcosdesign as recommended. You can actually get the actual MATLAB code for this function by typing the following lines in your MATLAB's command window: edit rcosdesign (you can also check edit firrcos). This opens a new editor window with the actual code for the function. This can help you.

Note that in your EDIT1, Fc is actually the cutoff (not carrier) frequency if you double-check the documentation, and that with three input arguments as you have the default $$F_s = 2$$. The roll-off factor is a measure of the excess bandwidth expressed as a fraction. The span of the filter in symbols is for you to define.

To add to what has been mentioned by @MBaz, what you need at the transmitter is the root-raised cosine filter. This is so that at the receiver side you also put a root-raised cosine and the two together result in a raised-cosine filter which is a Nyquist filter with zero ISI while the root-raised cosine doesn't exhibit zeros (in amplitude) at symbol times.

EDIT:

To see the equivalence between the two functions you'll have to give the correct input parameters to both functions. As discussed, first things is having a root-raised cosine. You can do this by setting the 6th and 4th input of firrcos and rcosdesign respectively to sqrt. The equivalents of the remaining parameters are as follows:

beta = R;
sps = Fs/(2*Fc);
span = N / sps;

Then you have the unnormalized two filters as:

h1 = firrcos(N, Fc, R, Fs, 'rolloff', 'sqrt');
h2 = rcosdesign(R, N/(Fs/Fc/2), Fs/Fc/2, 'sqrt');

More on this together with the needed normalization can be found in MATLAB's Communications Toolbox™ Release Notes for R2020b under the chapter on R2013b (I guess it got discontinued after then) titled Functionality Being Changed or Removed.

For your Simulink, click on Simulink Library Browser then on the list on your left choose Communications Toolbox then pick Comm Filters. There you have all your filters, you can set the chosen raised-cosine filter as discussed up.

• how to rewrite firrcos(20,0.25,0.25); to rcosdesign? Feb 8 '21 at 10:17
• @Ali23, please see the edit in my answer above. Feb 9 '21 at 10:35
• @Ali23, if this has answered your question remember to accept the answer. Feb 9 '21 at 15:41

The raised-cosine filter impulse response is documented in many textbooks and in Wikpedia here. All you need to do is implement that impulse response in your C program.

If you are transmitting data, you should really be using a root raised-cosine filter (raised cosine pulses are not orthogonal). Their impulse response is here.

• will be it enough for simulation it in hardware (FPGA)? Feb 2 '21 at 15:45
• What do you mean by "enough"?
– MBaz
Feb 2 '21 at 18:09