Advertisement
hiddenGem

Three Circular Loops

Jun 25th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.74 KB | None | 0 0
  1. %% Three Circular Loops
  2. % Calculates the magnetic field in three scenarios with a line and a
  3. %   circular loop: They are in the same direction, the opposite direction,a
  4. %   and they are perpendicular to each other
  5.  
  6. % Constants
  7. muNaught = 4*pi*10^-7;                  %[T*m/A] Vacuum Permeability
  8.  
  9. % Inputs and Variables
  10. I = input('What is the current?\n');
  11. r = input('What is the radius of the circle?\n');
  12.  
  13. % Output and Equations
  14. Bline = muNaught*I/(2*pi*r);
  15. Bcircle = pi*Bline;
  16. B = [Bline+Bcircle; abs(Bline-Bcircle); sqrt(Bline^2+Bcircle^2)];
  17. fprintf(['The magnitudes for the circle and loop in the same direction,\n'...
  18.         'opposite direction, and perpendicular are:\n'...
  19.         '%.4e T, %.4e T, and %.4e T\n'], B(1), B(2), B(3))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement