Advertisement
stiansjogren

Aykut, here u go

Nov 30th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.14 KB | None | 0 0
  1. % Lab 2 Digicom
  2. close all
  3.  
  4. % Read in sample file (example here)
  5. fd = fopen('usrp_samples.dat','r') ;
  6. s = fread(fd,153600*2,'int16') ;
  7. fclose(fd) ;
  8. s2 = s(1:2:end) + sqrt(-1)*s(2:2:end) ;
  9.  
  10.  
  11.  
  12.  
  13.  
  14. % close all
  15. %test = N_f;
  16. N_f = ind2; %needs to be changed for every new ind
  17. sss_e = [];
  18. ss0 = s2((N_f-72-1024-1023):(N_f-72-1024));
  19. pss0 = s2((N_f - 72-1023): (N_f - 72));
  20. p_f = fft(pss0, 1024);
  21. p_f2(1:36) =   p_f(1:36);
  22. p_f2(37:72)=  p_f(1024 + (-35:0) );
  23. s_f  = (fft(ss0,1024));
  24. figure;
  25. stem(abs(fftshift(s_f)))
  26. title 's_f'
  27. sss_e(1:36)= s_f((1024-35):1024);
  28. sss_e(37:72)= s_f(2:37);
  29. figure;
  30. stem(abs(sss_e));
  31.    figure;
  32.    plot(sss_e,'o')
  33.    axis([-10*power(10,5) 10*power(10,5) -10*power(10,5) 10*power(10,5)])
  34.    pss2_f_extracted = [];
  35.    i=6;
  36.    pss2_f_extracted = zeros(1,72);
  37.    for j=1:1:1024
  38.         if (abs(pss2_f(j))~= 0)
  39.            
  40.             pss2_f_extracted(i) = pss2_f(j);
  41.             i=i+1;
  42.         end
  43.    end
  44.    %pss2_f_extracted(end:end+5) = 0
  45.    H_n = abs(conj(pss2_f_extracted).* sss_e);
  46.    figure; stem(20*log10(abs(H_n))); axis([0 72 0 250])
  47.    
  48.    
  49.  
  50. % c)
  51.  
  52. %h_pss = cconv(conj(pss_2f),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement