Advertisement
Ladislav

Function example

Apr 22nd, 2012
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.13 KB | None | 0 0
  1. function [ f, Zin ] = funkce( fileName, isGrid, lineWidth )
  2.  
  3. profile clear;
  4. profile on;
  5.  
  6. if (nargin < 2)
  7.     isGrid = true;
  8. end;
  9.  
  10. if (nargin < 3)
  11.     lineWidth = 2;
  12. end;
  13.  
  14. if (exist(fileName, 'file') == 0)
  15.     error('myApp:filenotfound', 'Soubor neexistuje.');
  16. end;
  17.  
  18. S11 = xlsread(fileName);
  19.  
  20. if (length(S11) > 5000)
  21.     warning('myApp:longfile', 'Soubor je delÜφ ne₧ 5000 °ßdk∙.');
  22. end;
  23.  
  24. S11 = [S11(:,1), S11(:,2) .* exp(1i * S11(:,3) / 180 * pi)];
  25.  
  26. Z0 = 50;
  27. Zin = Z0 .* ((1 + S11(:,2)) ./ (1 - S11(:,2)));
  28. f = S11(:,1);
  29.  
  30. figure('Name', 'Vstupnφ impedance');
  31. plot(f, real(Zin), 'Color', 'blue', 'LineWidth', lineWidth, 'DisplayName', 'Real part');
  32. hold on;
  33. plot(f, imag(Zin), 'Color', 'green', 'LineWidth', lineWidth, 'DisplayName', 'Imaginary part');
  34. title('Vstupnφ impedance');
  35. xlabel('f [GHz]');
  36. ylabel('Zin [\Omega]');
  37. legend show;
  38. if(isGrid)
  39.     grid on;
  40. end;
  41.  
  42. figure('Name', 'Koeficient odrazu');
  43. plot(f, abs(S11(:,2)), 'Color', 'blue', 'LineWidth', lineWidth);
  44. title('Koeficient odrazu');
  45. xlabel('f [GHz]');
  46. ylabel('|S11|');
  47. if(isGrid)
  48.     grid on;
  49. end;
  50.  
  51. profile off;
  52. profile report;
  53.  
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement