Tuesday, 1 December 2015

HOW TO WRITE MATLAB CODE FOR FSK?

FSK:

Frequency-shift keying (FSK) is a frequency modulation scheme in which digital information is transmitted through discrete frequency changes of a carrier wave. 
he FSK 

CODING:
 clc;
 close all;
 clear all;
 x=input('enter the binary input = ');
 l=length(x);
 for i=1:1:l
 m(((i-1)*100)+1:i*100)=x(i);
 end
 figure;
 subplot(4,1,1);
 plot(m);
 xlabel('time');
 ylabel('amplitude');
 title('modulating signal');
 f=100;
 t=0:(1/f):(l-(1/f));
 f1=10;
 f2=5;
 c1=sin(2*pi*f1*t);
 y1=m.*c1;
 subplot(4,1,2);
 plot(t,y1);
 xlabel('time');
 ylabel('amplitude');
 for j=1:l
 if x(j)==1
 x(j)=0;
else x(j)=1;
     end
 m1((j-1)*100+1:j*100)=x(j);
end
 c2=sin(2*pi*f2*t);
 y2=m1.*c2;
 subplot(4,1,3);
 plot(t,y2);
 xlabel('time');
 ylabel('amplitude');
 y=y1+y2;
 subplot(4,1,4);
 plot(t,y);
 xlabel('time');
 ylabel('amplitude');
 title('FSK modulated wave');
 r=randn(size(y));
 F=y+r;
 figure;
 subplot(3,1,1);
 plot(F);
 xlabel('time');
 ylabel('amplitude');
 title('noise added FSK signal');
 l1=length(F);
 t1=0:0.01:.99;
 r1=sin(2*pi*f1*t1);
 r1=fliplr(r1);
 l2=length(r1);
 l3=l1+l2-1;
 u=fft(F,l3);
 v=fft(r1,l3);
 k1=u.*v;
 k11=ifft(k1,l3);
 r2=sin(2*pi*f2*t1);
 r2=fliplr(r2);
 w=fft(r2,l3);
 k2=u.*w;
 k22=ifft(k2,l3);
 k=k11-k22;
 subplot(3,1,2);
 plot(k);
 xlabel('time');
 ylabel('amplitude');
   title('correlated signal');
 for z=1:l
t(z)=k(z*100);
 if t(z)>0
 s(z)=1;
 else
 s(z)=0;
 end
 end
 subplot(3,1,3);
 tem(s);
 xlabel('time');
 ylabel('amplitude');
 title('Demodulated output signal'); 


OUTPUT:

























   
                                                        Fig: FSK Modulation
 FOR MORE DETAILS:


                                                 CLICK HERE


No comments:

Post a Comment