Advertisement
Stybyk

FSK -Complete

Dec 5th, 2015
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.92 KB | None | 0 0
  1. data1 =[0,1,0]
  2. function CPkeying(data ,fzero ,fone)
  3. if(fone >fzero)
  4.   fs = 10* fone;
  5.  
  6. else
  7.   fs = 10 * fzero
  8.  
  9. endif
  10.  
  11. Ts = 1/fs;
  12.  
  13. for i = 1:size(data,2)
  14.  if(data(i) == 0)
  15.   f(i) = fzero;
  16.   else
  17.    f(i) = fone;
  18.  
  19.  endif
  20.  endfor
  21.  
  22. for k = 1:size(data,2)
  23.    if(f(k) == fzero)
  24.     samples(end+1:end+fs) = fzero;
  25.     endif
  26.    if(f(k) == fone)
  27.     samples(end+1:end+fs) = fone;
  28. endif
  29. endfor
  30.  
  31. L = size(samples,2) - Ts;
  32. t1 = 0:Ts:(L/fs);
  33.  
  34. signal = sin(2*pi*samples.*t1);
  35. N = length(signal);
  36.  
  37.  
  38. X_mags = abs(fftshift(fft(signal)));
  39. bin_vals = [0 : N-1];
  40. N_2 = ceil(N/2);
  41. fax_Hz = (bin_vals-N_2)*fs/N;
  42. figure(1)
  43. subplot(2,1,1)
  44. plot(fax_Hz, X_mags)
  45. xlabel('Frekvence (Hz)')
  46. ylabel('Rozsah');
  47. title('Frekvenční spektrum');
  48. axis tight
  49.  
  50. subplot(2,1,2)
  51.  
  52.  
  53. plot(t1,signal)
  54.  
  55. xlabel('Čas')
  56. ylabel('Amplituda');
  57. title('Časová oblast');
  58. axis tight
  59.  
  60.  
  61. endfunction
  62.  
  63.  
  64. CPkeying(data1,2,5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement