Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. clear all;
  2. close all;
  3. clc;
  4.  
  5. %% 1) Dane
  6. load('cr_n1.mat');
  7.  
  8. fs = 2e5;
  9. f = linspace(-fs/2,fs/2,length(rxSig));
  10.  
  11.  
  12. %% 2) widmo odebranego:
  13. rxSigFFT = abs(fft(rxSig)); % Cha-ka a-cz sygnalu odbieranego
  14.  
  15. figure;
  16. plot(f, [rxSigFFT(length(rxSigFFT)/2:end);rxSigFFT(1:length(rxSigFFT)/2-1)]);
  17. title('Cha-ka a-cz sygnalu odbieranego');
  18. xlabel('[kHz]');
  19.  
  20.  
  21. %% 3) Przesunięcie do BB
  22. rxSig2 = rxSig.^4;
  23. NFFT = length(rxSig2)*50;
  24. rxSigFFT2 = abs(fft(rxSig2, NFFT));
  25. f2 = linspace(-fs/2,fs/2,length(rxSigFFT2));
  26. figure;
  27. plot(f2, [rxSigFFT2(length(rxSigFFT2)/2:end);rxSigFFT2(1:length(rxSigFFT2)/2-1)]); %sta�a, no�na, szybko�� symbolowa
  28. title('Sygna� podniesiony do 4 pot�gi; sta�a, no�na, szybko�� symbolowa');
  29. xlabel('Frequency [Hz]');
  30. [val, offsetIndex] = max([rxSigFFT2(length(rxSigFFT2)/2:end);rxSigFFT2(1:length(rxSigFFT2)/2-1)]);
  31. fshift = f2(offsetIndex)/4;
  32.  
  33. %% 4) Przesuniecie do BB
  34. rxSig = rxSig .* exp(2*pi*1j*fshift/fs*(0:length(rxSig)-1))'; % Przesuwamy sygnal do zera Hz (BB)
  35.  
  36. %% 5) widmo przesunietego do BB:
  37. rxSigFFTshifted = abs(fft(rxSig));
  38.  
  39. figure;
  40. plot(f, [rxSigFFTshifted(length(rxSigFFTshifted)/2:end);rxSigFFTshifted(1:length(rxSigFFTshifted)/2-1)]);
  41. title('Cha-ka a-cz sygnalu przesunietego do BB');
  42. xlabel('Frequency [Hz]');
  43.  
  44. %% Wyrkes konstelacji - dane
  45. rolloff = 0.35; % wsp poszerzenia pasma
  46.  
  47. span = 8; % liczba odfiltrowanych symboli
  48.  
  49. sps = 100; % liczba probek na symbol
  50.  
  51. %% Wykres konstelacji przed resamplingiem
  52. constellation_before = scatterplot(rxSig); %diagram konstelacji
  53.  
  54. %% resampling
  55. b = rcosdesign(rolloff, span, sps); % filtr podniesiony cosinus do obnizenia cz. probkowania
  56. newFs = 2e3;
  57. [L,M] = rat(fs/newFs);
  58. disp(int2str(round(fs/newFs)))
  59. resampledSig = upfirdn(rxSig, b, M, L);
  60. delay = floor(((filtord(b)-1)/2-(L-1))/L); %liczenie opoznienia sygnalu przez filter
  61. resampledSig = resampledSig(delay+1:end); %przesuniecie sygnalu o delay
  62. %% Wyrkes konstelacji ppo resamplingu
  63. constellation_after = scatterplot(resampledSig); %diagram konstelacji
  64.  
  65. %% Widmo po resamplingu
  66.  
  67. resampledSigFFT = abs(fft(resampledSig));
  68. fResampled = linspace(-newFs/2,newFs/2,length(resampledSig));
  69.  
  70. if (mod(length(fResampled), 2) > 0)
  71. fResampled(length(fResampled)+1) = 0;
  72. resampledSigFFT(length(resampledSigFFT)+1) = 0;
  73. end
  74. %% Wykres widma po resamplingu
  75. figure;
  76. plot(fResampled, [resampledSigFFT(length(resampledSigFFT)/2:end);resampledSigFFT(1:length(resampledSigFFT)/2-1)]);
  77. title('Cha-ka a-cz sygnalu po resamplingu');
  78. xlabel('Frequency [Hz]');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement