Guest User

Untitled

a guest
Jan 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.49 KB | None | 0 0
  1. % Definimos el paso y los dos vectores de posibles valores de la función.
  2.  
  3. delta = (2*pi)/50;
  4. theta = 0.001:delta/2:pi+0.001;
  5. phi = 0:delta:(2*pi);
  6. n = [1, 2, 3, 4, 5, 10, 25, 50:93];
  7. n(50<n) = 0;
  8. [Theta, Phi] = meshgrid(theta, phi);
  9. [M, N] = meshgrid(theta, n);
  10.  
  11. % Definimos la función a representar.
  12.  
  13. i = 1;
  14.  
  15. if i == 1
  16.     funcion = (sin(2.5*pi*sin(Theta))./(2.5*pi*sin(Theta)))^2;
  17. elseif i == 2
  18.     funcion = (sin(7*pi*sin(Theta))./(7*pi*sin(Theta)))^2;
  19. else
  20.     funcion = (cos(Theta)).^N;
  21. end
  22.  
  23. % Dividimos la función entre su valor máximo para normalizar entre 0 y 1.
  24.  
  25. funcion = funcion/max(max(funcion));
  26.  
  27. % Obtenemos las componentes cartesianas de la función.
  28.  
  29. x = funcion.*sin(Theta).*cos(Phi);
  30. y = funcion.*sin(Theta).*sin(Phi);
  31. z = funcion.*cos(Theta);
  32.  
  33. % Y representamos la función con los ejes normalizados entre -30 y 0 dB.
  34.  
  35. pantalla = get(0, 'ScreenSize');
  36. ventana = [pantalla(3)/2-300, pantalla(4)/2-300, 600, 600];
  37. figure('Name', 'Diagrama de radiación en 3D', 'Position', ventana);
  38.  
  39. surf(x, y, z);
  40.  
  41. axis equal;
  42. xlim([-1, 1]);
  43. ylim([-1, 1]);
  44. zlim([-1, 1]);
  45.  
  46. xlabel('dB');
  47. ylabel('dB');
  48. zlabel('dB');
  49.  
  50. L1 = get(gca, 'XLim');
  51. set(gca, 'XTick', linspace(L1(1), L1(2), 6));
  52. L2 = get(gca, 'YLim');
  53. set(gca, 'YTick', linspace(L2(1), L2(2), 6));
  54. L3 = get(gca, 'ZLim');
  55. set(gca, 'ZTick', linspace(L3(1), L3(2), 11));
  56.  
  57. set(gca, 'XTickLabel', {0:-12:-30; -24:12:0});
  58. set(gca, 'YTickLabel', {0:-12:-30; -24:12:0});
  59. set(gca, 'ZTickLabel', {0:-6:-30; -24:6:0});
Add Comment
Please, Sign In to add comment