• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest May 19th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. clc;
2. clear all;
3. close all;
4. %GENERATE CARRIER SIGNAL
5. Tb=1; fc1=2;fc2=5;
6. t=0:(Tb/100):Tb;
7. c1=sqrt(2/Tb)*sin(2*pi*fc1*t);
8. c2=sqrt(2/Tb)*sin(2*pi*fc2*t);
9.  %generate message signal
10. N=8;
11. m=rand(1,N);
12. t1=0;t2=Tb
13. for i=1:N
14.  t=[t1:(Tb/100):t2]
15.  if m(i)>0.5
16.  m(i)=1;
17.  m_s=ones(1,length(t));
18.  invm_s=zeros(1,length(t));
19.  else
20.  m(i)=0;
21.  m_s=zeros(1,length(t));
22.  invm_s=ones(1,length(t));
23.  end
24.  message(i,:)=m_s;
25.  %Multiplier
26.  fsk_sig1(i,:)=c1.*m_s;
27.  fsk_sig2(i,:)=c2.*invm_s;
28.  fsk=fsk_sig1+fsk_sig2;
29.
30.
31.  %plotting the message signal and the modulated signal
32.  subplot(3,2,2);axis([0 N -2 2]);plot(t,message(i,:),'r');
33.  title('message signal');xlabel('t---->');ylabel('m(t)');grid on;hold on;
34.  subplot(3,2,5);plot(t,fsk(i,:));
35.  title('FSK signal');xlabel('t---->');ylabel('s(t)');grid on;hold on;
36.  t1=t1+(Tb+.01); t2=t2+(Tb+.01);
37.  end
38. hold off
39. %Plotting binary data bits and carrier signal
40. subplot(3,2,1);stem(m);
41. title('binary data');xlabel('n---->'); ylabel('b(n)');grid on;
42. subplot(3,2,3);plot(t,c1);
43. title('carrier signal-1');xlabel('t---->');ylabel('c1(t)');grid on;
44. subplot(3,2,4);plot(t,c2);
45. title('carrier signal-2');xlabel('t---->');ylabel('c2(t)');grid on
46.
47.
48.
49. t1=0;t2=Tb
50.  for i=1:N
51.  t=[t1:(Tb/100):t2]
52.  %correlator
53.  x1=sum(c1.*fsk_sig1(i,:));
54.  x2=sum(c2.*fsk_sig2(i,:));
55.  x=x1-x2;
56.  %decision device
57.  if x>0
58.  demod(i)=1;
59.  else
60.  demod(i)=0;
61.  end
62.  t1=t1+(Tb+.01);
63.  t2=t2+(Tb+.01);
64.  end
65.
66.
67.  %Plotting the demodulated data bits
68.  subplot(3,2,6);stem(demod);
69.  title(' demodulated data');xlabel('n---->');ylabel('b(n)'); grid on;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top