hiddenGem

Two Parallel Wires

Jun 25th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.90 KB | None | 0 0
  1. %% Two Parallel Wires
  2. % Determines the magnetic field from two parallel wires from two different
  3. %    spots.
  4.  
  5. % Constants
  6. muNaught = (4*pi)*10^-7 ;                %[T*m/A] Vacuum Permeability
  7. B = muNaught/(2*pi);        
  8.  
  9. % Inputs and Variables
  10. I = input('Input the currents in brackets\n');
  11. dQ = input('Input the distance from the currents to the point between them in brackets\n');
  12. dP = input('Input the distance from the currents to the point outside the wires in brackets\n ');
  13.  
  14. % Outputs and Equations
  15. bq1 = B*I(1)/dQ(1);
  16. bq2 = B*I(2)/dQ(2);
  17. bp1 = B*I(1)/dP(1);
  18. bp2 = B*I(2)/dP(2);
  19. Q = bq1-bq2;
  20. P = bp1+bp2;
  21. fprintf('The magnetic field at the point between and outside the two wires are %.4e T and %.4e T', Q,P)
  22.  
  23. %{
  24. 'B' really isn't a constant but just a multiplying factor used many times
  25.     and I was just too lazy to type it out.
  26. When the user is asked to input the distance from the parallel wires it
  27.     should be as follows: [distance from wire 1 to the middle point, distance
  28.     from wire 2 to the middle point]. The order of the distances should
  29.     match the order of the currents in the input from the line above.
  30. Under the assumption where Q is between the wires and P is somewhere to the
  31.     outside of one of thee wires. The code might be fallible whether or not
  32.     the sign of the values are right based on the direction of the long
  33.     wires. This particular code runs where the two parallel wire run in the
  34.     same direction
  35. Very similar to the Long Wire script but this deals with parallel wires
  36.     going alongside the page where the other script deals with the wire going
  37.     in or out of the page.
  38. To calculate the magnetic field at 'Q' the magnetic fields from the two
  39.     wires, they must be subtracted because the forces are in opposite
  40.     directions. On the other hand to calculate 'P' the magnetic fields must
  41.     be added because they are in the same direction.
  42. %}
Add Comment
Please, Sign In to add comment