fading channel

by

 

simulation for a rayleigh fading channel

a_envelope(K,fd,Ts,fc,A,sigma,attn);
function p = a_envelope(K,fd,Ts,fc,A,sigma,attn);
%to obtain a(k)'s plot and power received. 
%typical values fc=2.4*10^9,K=200,fd=0 to 15 hz.
%q = (-fd+1):0.1:(fd+1);%interval for freq Histogram
l=0;
for  k=1:K    
    a(k)=sigma*randn(1);
    sign=(-1)^k;
    fk(k)= ceil(sign*fd*rand(1));
    b(k)=a(k)*exp(j*2*pi*fk(k));
    x(k)= A*exp(j*2*pi*fc*k*Ts);
    y(k)=b(k)*x(k);
    
    if (fk(k)==0)
        l=l+1;
        g(l)=a(k);
    end

end

if l==0
    g(1)=0;
end

%subplot(4,5,1);plot(a),xlabel('Path no.(k)'),ylabel('ak');
%subplot(4,5,6);plot(abs(b)),xlabel('Path no.(k)'),ylabel('bk');

%subplot(4,5,2);hist(a,50),xlabel('ak'),ylabel('#repeatations');%plot distribution of 'a'
%subplot(4,5,7);hist(fk,q),xlabel('fk'),ylabel('#repeatations');%plot 

%subplot(4,5,3);plot(real(x),'b-'),xlabel('t'),ylabel('Input sig');%plot input signal
%subplot(4,5,8);plot(real(y),'r-'),xlabel('t'),ylabel('Output');%plot output signal

p=attn*abs([sum(g.^2)/K]*1/2);
%p=abs([sum(b.^2)/K]*1/2);

for  w=1:K    
    x1(w)= exp(j*2*pi*fc*w*1/(2*fc));
    y1(w)=attn*b(w)*x(w);
end;
%subplot(4,5,4);plot(20*log10(abs(real(x1)))),xlabel('t'),ylabel('input power');%input power
%subplot(4,5,9);plot(20*log10(abs(real(y1))),'k-'),xlabel('t'),ylabel('output power');%output power

%subplot(4,5,5);plot(D);
%subplot(4,5,10);plot(a)

Contact us