Advertisement
makispaiktis

Eidikes - Ergasia 1 - coneCoordinates

Mar 27th, 2021 (edited)
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.05 KB | None | 0 0
  1. clear all
  2. clc
  3.  
  4. lamda = 0.1;
  5. l = 0.5 * lamda;
  6. theta0 = pi/6;
  7. N = 20;
  8. segments = 5;
  9. % Από το ορθογώνιο τρίγωνο που δημιουργείται
  10. r = l * sin(pi/6);
  11. h = l * cos(pi/6);
  12. offsetZ = lamda / 20;
  13. diameter = lamda / 100;
  14. theta = 0: 2*pi / N : 2*pi - 2*pi / N
  15.  
  16. % 1. Συντεαταγμένες αρχής
  17. xStart = [];
  18. yStart = [];
  19. zStart = [];
  20. for i = 1:N
  21.     xStart(i) = 0;
  22.     yStart(i) = 0;
  23.     zStart(i) = offsetZ;
  24. end
  25.  
  26. % 2. Συντεταγμένες τέλους
  27. xEnd = [];
  28. yEnd = [];
  29. zEnd = [];
  30. for i = 1:N
  31.     zEnd(i) = offsetZ + h;
  32.     xEnd(i) = r * cos(theta(i));
  33.     yEnd(i) = r * sin(theta(i));
  34. end
  35.  
  36. xStart
  37. yStart
  38. zStart
  39. xEnd
  40. yEnd
  41. zEnd
  42.  
  43. % 3. Φτιάξιμο αρχείου - Τα νέα wires θα έχουν αύξοντα από 21 ως 40
  44. coneFile = fopen('coneCoordinates.nec', 'w');
  45. format = 'GW %d %d %f %f %f %f %f %f %f\n';
  46. for i = 1:N
  47.     fprintf(coneFile, format, i+20, segments, xStart(i), yStart(i), zStart(i), xEnd(i), yEnd(i), zEnd(i), diameter/2);
  48. end
  49.  
  50. fclose(coneFile);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement