Advertisement
hiddenGem

Regular Hexagon Shaped Loop

Jun 25th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.78 KB | None | 0 0
  1. %% Regular Hexagon Shaped Loop
  2. % Determines the size of the magnetic field at the center and at one of the
  3. %    corners of a regular hexagon
  4.  
  5. % Constants
  6. muNaught = (4*pi)*10^-7 ;                %[T*m/A] Vacuum Permeability
  7. arb = (2*sqrt(3)-1)/12;
  8.  
  9. % Inputs and Variables
  10. a = input('What is the length of the side?\n');
  11. I = input('What is the current of the loop\n');
  12.  
  13. % Outputs and Equations
  14. Bcent = sqrt(3)*muNaught*I/(pi*a);
  15. Bcorn = Bcent*arb;
  16. fprintf(['The magnitude at the center of the regular hexagon and at one of the corners are:\n'...
  17.         '%4e T and %.4e T\n'], Bcent, Bcorn)
  18.  
  19. %{
  20. The variable 'arb' in the constants section is just a placeholder. It is
  21.     not an actual constant. It just makes the line in the outputs and equations
  22.     section less crowded
  23. %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement