Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Magnetic field contour

  1. Oct 18, 2013 #1
    Hello everyone,

    I am struggling a bit with a Matlab program that I am writing. I am supposed to create a contour of the magnitude of the magnetic field, in and out of a wire. Basically the function is

    |B| = r for -1≤r≤ 1 and |B| = 1/r for -3≤r≤-1 & 1≤r≤3
    where r is the radius

    However the contour that I have to plot is for |B| from 0.2 to 1 with steps of 0.2 (0.2, 0.4, 0.6, 0.8, 1.0) and it also has to be in Cartesian coordinates x,y both from -3 to 3.

    What I've gotten so far is :

    B1 = sqrt(x.^2+y.^2);
    (for inside the wire)

    B2 = 1./(sqrt((x1).^2+(y1).^2));
    (outside the wire)

    hold all;
    hold off;

    In conclusion my problem is how to limit both B1 and B2 for value only equals to the ones above.
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted