Hi, if anyone good with matlab and knows biot savart law then i hope you can help. I have the following program:(adsbygoogle = window.adsbygoogle || []).push({});

all lines in red are currently not calculating what I want them to. Can anyone help? Thanks!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

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab: help with biot savart law

Loading...

Similar Threads - Matlab help biot | Date |
---|---|

Matlab MATLab: Not enough inputs for nlinfit | Nov 16, 2017 |

Matlab Help needed to fix a matlab code | Nov 8, 2017 |

New to Matlab, help with vectors | Feb 20, 2016 |

Need help with integral | Dec 23, 2015 |

Communication between Arduino and Matlab Help | Jun 19, 2015 |

**Physics Forums - The Fusion of Science and Community**