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

Matlab: biot savart law

  1. Apr 22, 2012 #1
    Hi, if anyone good with matlab and knows biot savart law then i hope you can help. I have the following program:

    Code (Text):

     clear all
     Img = imread('littlecircle.png');
     Img = Img(:,:,1);
     Img = double(Img);
     w = size(Img,1);               % width size
     h = size(Img,2);               % height size
     [Ix,Iy] = gradient(Img);       %gradient of image
     
     i=1;     %iteration for magnetic field loop
     b=0;     %initialize b to zero
     
     % Magnetic Field
     for pxRow = 1:h % fixed pixel row
     for pxCol = 1:w % fixed pixel column
     
     for r = 1:h % row of distant pixel
     for c = 1:w % column of distant pixel
     
     R(c,r) = sqrt((r-pxRow)^2 + (c-pxCol)^2);                               % pythagoras theorem to get distance to each pixel
    [COLOR="Red"] O(c,r) = atan(Iy(c,r)./Ix(c,r));                         % direction of current
     If(c,r) = sqrt((Ix(c,r)).^2 + (Iy(c,r)).^2);                            % magnitude of current
     Rxs(c,r) = R(c,r)./norm(R(c,r));                                        % unit vector from x to s                    
     b(c,r) = If(c,r).*O(c,r).*(Rxs(c,r)./(R(c,r)).^2);                      % b field = If(s)O(s) x Rxs/R.^2  BIOT SAVART LAW[/COLOR]Rxs/R.^2  BIOT SAVART LAW
     end
     end
     B(i) = {b}; % filling a cell array with results. read below
     i = i+1;
     end
     end
    all lines in red are currently not calculating what I want them to. Can anyone help? Thanks!
     
  2. jcsd
  3. Apr 22, 2012 #2
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Matlab: biot savart law
  1. Matlab and tables (Replies: 0)

  2. Simple Matlab (Replies: 2)

  3. Arduino and Matlab (Replies: 1)

Loading...