Advertisement
makispaiktis

Eidikes - Ergasia 1 - createCoordinates2.m

Mar 28th, 2021 (edited)
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 3.38 KB | None | 0 0
  1. clear all
  2. clc
  3.  
  4. % ========================================================================
  5. % ================================= Data =================================
  6. % ========================================================================
  7. lamda = 0.1;
  8. f = 3000;        % Mhz, due to 0.1m wavelength
  9. N = 8;
  10. theta = 0 : 2*pi/N : 2*pi - 2*pi / N;
  11. diameter = lamda / 100;
  12. segments = 5;
  13. % Δίσκος
  14. rDisc = 0.3 * lamda;
  15. % Κώνος
  16. l = 0.5 * lamda;
  17. theta0 = pi/6;
  18. rCone = l * sin(pi/6);
  19. h = l * cos(pi/6);
  20. % Μεσαίο segment τροφοδοσίας
  21. offsetZ = lamda / 20;
  22.  
  23.  
  24. % ========================================================================
  25. % ============================== Coordinates =============================
  26. % ========================================================================
  27. % 1. Συντεταγμένες αρχής δίσκου
  28. xDiscStart = [];
  29. yDiscStart = [];
  30. zDiscStart = [];
  31. for i = 1:N
  32.     xDiscStart(i) = 0;
  33.     yDiscStart(i) = 0;
  34.     zDiscStart(i) = 0;
  35. end
  36.  
  37.  
  38. % 2. Συντεταγμένες τέλους δίσκου
  39. xDiscEnd = [];
  40. yDiscEnd = [];
  41. zDiscEnd = [];
  42. for i = 1:N
  43.     zDiscEnd(i) = 0;
  44.     xDiscEnd(i) = rDisc * cos(theta(i));
  45.     yDiscEnd(i) = rDisc * sin(theta(i));
  46. end
  47.  
  48. % 3. Συντεαταγμένες αρχής κώνου
  49. xConeStart = [];
  50. yConeStart = [];
  51. zConeStart = [];
  52. for i = 1:N
  53.     xConeStart(i) = 0;
  54.     yConeStart(i) = 0;
  55.     zConeStart(i) = offsetZ;
  56. end
  57.  
  58. % 4. Συντεταγμένες τέλους κώνου
  59. xConeEnd = [];
  60. yConeEnd = [];
  61. zConeEnd = [];
  62. a = (pi / 6) / (N-1);
  63. for i = 1:N
  64.     xConeEnd(i) = 0;
  65. end
  66. for i = 1:2:N-1               % i = 1,3,5,7
  67.     zConeEnd(i) = l * cos(a/2 + (i-1)*a);
  68.     zConeEnd(i+1) = l * cos(a/2 + (i-1)*a);
  69.     yConeEnd(i) = l * sin(a/2 + (i-1)*a);
  70.     yConeEnd(i+1) = - l * sin(a/2 + (i-1)*a);
  71. end
  72.  
  73. xConeEnd
  74. yConeEnd
  75. zConeEnd
  76.  
  77.  
  78. % ========================================================================
  79. % ================================ fprintf ===============================
  80. % ========================================================================
  81. geometryFile = fopen('ErgasiaFlat.nec', 'w');
  82. % Αρχή .nec αρχείου
  83. fprintf(geometryFile, 'CM Disc-cone antenna Question D: 8 wires for disc and 8 more for cone\n');
  84. fprintf(geometryFile, 'CM Boufikos Thomas 9360\nCE\n\n');
  85. % Δίσκος
  86. format = 'GW %d %d %f %f %f %f %f %f %f\n';
  87. for i = 1:N
  88.     fprintf(geometryFile, format, i, segments, xDiscStart(i), yDiscStart(i), zDiscStart(i), xDiscEnd(i), yDiscEnd(i), zDiscEnd(i), diameter/2);
  89. end
  90. % Κώνος
  91. format = 'GW %d %d %f %f %f %f %f %f %f\n';
  92. for i = 1:N
  93.     fprintf(geometryFile, format, i+N, segments, xConeStart(i), yConeStart(i), zConeStart(i), xConeEnd(i), yConeEnd(i), zConeEnd(i), diameter/2);
  94. end
  95. % Μεσαίο segment τροφοδοσίας
  96. xFeedStart = 0;
  97. yFeedStart = 0;
  98. zFeedStart = 0;
  99. xFeedEnd = 0;
  100. yFeedEnd = 0;
  101. zFeedEnd = lamda/20;
  102. format = 'GW %d %d %f %f %f %f %f %f %f\n';
  103. segmentsFeed = 1;
  104. fprintf(geometryFile, format, N+N+1, segmentsFeed, xFeedStart, yFeedStart, zFeedStart, xFeedEnd, yFeedEnd, zFeedEnd, diameter/2);
  105.  
  106. % Λοιπές λεπτομέρειες
  107. isThereGround = 0;
  108. fprintf(geometryFile, '\n\nGE %d\n', isThereGround);
  109. fprintf(geometryFile, 'EX 0 %d %d 0 1 0\n', N+N+1, segmentsFeed);
  110. fprintf(geometryFile, 'FR 0 1 0 0 %d 0\n\n', f);
  111. fprintf(geometryFile, 'EN');
  112.  
  113. fclose(geometryFile);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement