th0m45s5helby

chakri DC aug

Feb 25th, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. %>>>>>>>>> MATLAB code for binary FSK modulation and de-modulation >>>>>>>%
  2.  
  3. clc;
  4. clear all;
  5. close all;
  6.  
  7.  
  8. x=[ 1 0 0 1 1 0 1]; % Binary Information
  9. bp=.000001; % bit period
  10. disp(' Binary information at Trans mitter :');
  11. disp(x);
  12.  
  13. %XX representation of transmitting binary information as digital signal XXX
  14. bit=[];
  15. for n=1:1:length(x)
  16. if x(n)==1;
  17. se=ones(1,100);
  18. else x(n)==0;
  19. se=zeros(1,100);
  20. end
  21. bit=[bit se];
  22.  
  23. end
  24. t1=bp/100:bp/100:100*length(x)*(bp/100);
  25. subplot(3,1,1);
  26. plot(t1,bit,'lineWidth',2.5);grid on;
  27. axis([ 0 bp*length(x) -.5 1.5]);
  28. ylabel('amplitude(volt)');
  29. xlabel(' time(sec)');
  30. title('transmitting information as digital signal');
  31.  
  32.  
  33.  
  34. %XXXXXXXXXXXXXXXXXXXXXXX Binary-FSK modulation XXXXXXXXXXXXXXXXXXXXXXXXXXX%
  35. A=5; % Amplitude of carrier signal
  36. br=1/bp; % bit rate
  37. f1=br*8; % carrier frequency for information as 1
  38. f2=br*2; % carrier frequency for information as 0
  39. t2=bp/99:bp/99:bp;
  40. ss=length(t2);
  41. m=[];
  42. for (i=1:1:length(x))
  43. if (x(i)==1)
  44. y=A*cos(2*pi*f1*t2);
  45. else
  46. y=A*cos(2*pi*f2*t2);
  47. end
  48. m=[m y];
  49. end
  50. t3=bp/99:bp/99:bp*length(x);
  51. subplot(3,1,2);
  52. plot(t3,m);
  53. xlabel('time(sec)');
  54. ylabel('amplitude(volt)');
  55. title('waveform for binary FSK modulation coresponding binary information');
  56.  
  57.  
  58.  
  59.  
  60. %XXXXXXXXXXXXXXXXXXXX Binary FSK demodulation XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  61. mn=[];
  62. for n=ss:ss:length(m)
  63. t=bp/99:bp/99:bp;
  64. y1=cos(2*pi*f1*t); % carrier siignal for information 1
  65. y2=cos(2*pi*f2*t); % carrier siignal for information 0
  66. mm=y1.*m((n-(ss-1)):n);
  67. mmm=y2.*m((n-(ss-1)):n);
  68. t4=bp/99:bp/99:bp;
  69. z1=trapz(t4,mm) % intregation
  70. z2=trapz(t4,mmm) % intregation
  71. zz1=round(2*z1/bp)
  72. zz2= round(2*z2/bp)
  73. if(zz1>A/2) % logic lavel= (0+A)/2 or (A+0)/2 or 2.5 ( in this case)
  74. a=1;
  75. else(zz2>A/2)
  76. a=0;
  77. end
  78. mn=[mn a];
  79. end
  80. disp(' Binary information at Reciver :');
  81. disp(mn);
  82.  
  83.  
  84. %XXXXX Representation of binary information as digital signal which achived
  85. %after demodulation XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  86. bit=[];
  87. for n=1:length(mn);
  88. if mn(n)==1;
  89. se=ones(1,100);
  90. else mn(n)==0;
  91. se=zeros(1,100);
  92. end
  93. bit=[bit se];
  94.  
  95. end
  96. t4=bp/100:bp/100:100*length(mn)*(bp/100);
  97. subplot(3,1,3)
  98. plot(t4,bit,'LineWidth',2.5);grid on;
  99. axis([ 0 bp*length(mn) -.5 1.5]);
  100. ylabel('amplitude(volt)');
  101. xlabel(' time(sec)');
  102. title('recived information as digital signal after binary FSK demodulation');
  103.  
  104.  
  105.  
  106. %>>>>>>>>>>>>>>>>>>>>>>>>>> end of program >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>%
Add Comment
Please, Sign In to add comment