function [y,des_freq1]=Freq_RC(Freq,fc,Ts,alpha)
%Freq is the total nuber of frequency points being considered
%fc is the center frequency, choose it to coincide with some point in Freq
%Ts is the sample time
%alpha is the excess bandwidth

fmax=fc+1/(2*Ts)*(1+alpha);
fmin=fc-1/(2*Ts)*(1+alpha);
amax=fc+1/(2*Ts)*(1-alpha);
amin=fc-1/(2*Ts)*(1-alpha);

des_freq1=find(Freq>=fmin & Freq<=fmax);
a=min(des_freq1);

des_freq1(length(des_freq1));
des_freq2=find(Freq>=amin & Freq<=amax);
des_freq3=setdiff(des_freq1,des_freq2);
y=zeros(1,length(des_freq1));
y(des_freq3-a+1)=sqrt(Ts)/2*(1-sin((2*pi*abs((Freq(des_freq3)-fc))*Ts+pi)/(2*alpha)));
y(des_freq2-a+1)=sqrt(Ts);

%normalize energy to 1--> we know that integral of X^2(w) = 1 for
%normalized basis functions so use Simpson's Rule. We shall make
%the integral of the positive side of X^2(W)=sqrt(2) and then divide
%by two. NOTE THAT THE FREQUENCY SPACING SHOULD BE HIGH ENOUGH
%TO GET AN ACCURATE NUMERICAL INTEGRATION

alpha=sqrt(sqrt(2))/sqrt((abs(norm(y))^2)*(Freq(2)-Freq(1)));
y=y*alpha;
(norm(y)^2)*(Freq(2)-Freq(1));
y=y/2; %since modulated by a cos or sin

des_freq1=Freq(des_freq1);
