Advertisement
Guest User

Untitled

a guest
May 11th, 2017
1,441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. function ExamplePlotImpedances(code,no)
  2. % function ExamplePlotImpedances(src)
  3. %
  4. % Example program
  5. % Load and plot a group of impedance measurements from HP8753,
  6. % saved as S11-parameters
  7. % From functions written in LabVIEW at HBV-IMST
  8.  
  9. Zref = 50; % Ohm Reference impedance
  10.  
  11. %-- Build fileames --
  12. Nf = length(no);
  13. for k=1:Nf
  14. src{k}= sprintf('%s%04d.trc', code, no(k));
  15. end
  16.  
  17. for k=1:Nf
  18. %--- Load raw data ---
  19. trc(k)= readtrace(src{k});
  20.  
  21. %--- Create frequency vector, calculate Z, and plot impedance ---
  22. f{k}= [0:trc.Np-1]*trc.dx+trc.x0; % Hz Frequency vector
  23. end
  24.  
  25. S11{k} = double(trc.y(:,1)+ 1i*trc.y(:,2));
  26. Z = Zref* (1+S11{k})./(1-S11{k}); % Ohm Complex impdance
  27. end
  28. keyboard
  29. subplot(2,2,1)
  30. semilogy(f,abs(Z));
  31. xlabel('Frequency [Hz]')
  32. ylabel('Impedance magnitude [Ohm]')
  33. grid on
  34.  
  35. subplot(2,2,3)
  36. phi = angle(Z);
  37. plot(f,rad2deg(phi));
  38. xlabel('Frequency [Hz]')
  39. ylabel('Phase [deg]')
  40. ylim([-90 90])
  41. set(gca, 'ytick', [-90:30:90])
  42. grid on
  43.  
  44. subplot(2,2,2)
  45. plot(f, real(Z), 'b-', f, imag(Z), 'r-');
  46. xlabel('Frequency [Hz]')
  47. ylabel('Impedance [Ohm]')
  48. grid on
  49.  
  50. subplot(2,2,4)
  51. plot(f, real(S11), 'b-', f, imag(S11), 'r-');
  52. xlabel('Frequency [Hz]')r
  53. ylabel('S11')
  54. ylim([-1 1])
  55. grid on
  56.  
  57. keyboard
  58. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement