Magnetic Field for straight wire loop

13 Ansichten (letzte 30 Tage)
Daniel
Daniel am 31 Aug. 2012
Dear all,
I have a program that will use the Biot-Savart's law to calculate the magnetic field for my square loop. The problem I am having is when I done the integral:
(y-yp)/sqrt(r^2+(y-k)^2)^3 dy from y= -a to a ==> -1/ sqrt((yp-y)^2+r^2).
And for the program to work I have to have:
-1/ sqrt((yp-a)^2+r^2) - 1/ sqrt((yp+a)^2+r^2)
instead of the right way of integral:
-1/ sqrt((yp-a)^2+r^2) + 1/ sqrt((yp+a)^2+r^2).
In the program the wire is in the y direction and magnetic field calculated for x and z direction.
My question how come the normal integration will not work with the program.
Also a is the length of the wire and values divided for thousand because those are in mm and in my script values entered in m.
function [Bx,Bz]=m_field(I,a,x0,y0,z0,z,xmin,ymin,xmax,ymax,step)
%miu0=4*pi*10^-7;
miu0=1.25664E-6;
B0=(I*miu0)/(4*pi);
a=a/1000;
in1=1;
for x=xmin:step:xmax
in2=1;
for y=ymin:step:ymax
if (!(x==x0 & z==z0))
r=(sqrt((x-x0)^2+(z-z0)^2))/1000;
yp=(y-y0)/1000;
Bn=B0*((-1/sqrt(r^2+(yp-a)^2)) - (1/sqrt(r^2+(yp+a)^2)));
Bx(in1,in2)=(B*((z-z0)/1000/r));
Bz(in1,in2)=(B*((x-x0)/1000)/r);
else
Bx(in1,in2)=0;
Bz(in1,in2)=0;
end
X(in1,in2)=x;
Y(in1,in2)=y;
in2=in2+1;
end
in1=in1+1;
end
s=size(Bx);
for i=2:s(1)-1
for j=2:s(2)-1
if (Bx(i,j)==0 & Bz(i,j)==0)
Bz(i,j)=1/8*(Bz(i-1,j-1)+Bz(i-1,j+1)+Bz(i-1,j)+Bz(i,j-1)+Bz(i,j+1)+Bz(i+1,j-1)+Bz(i+1,j+1)+Bz(i+1,j));
end
end
end

Antworten (0)

Kategorien

Mehr zu Thermodynamics & Statistical Physics finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by