Java Scrap Book  

Java Scrap Book > MATLAB > flux

flux

% FLUX
function lab4
mu=4*pi*1e-7;
I=1.0;
end1=[0 0 -30];
end2=[0 0 30];
Number_of_Segments=250;
dL=(end2-end1)/Number_of_Segments;
aN=[-1 0 0];
NumberOfYSteps=20;
NumberOfZSteps=20;
ymin=1;
ymax=3;
zmin=0;
zmax=1;
dy=(ymax-ymin)/NumberOfYSteps;
dz=(zmax-zmin)/NumberOfZSteps;
flux=0;
dS=dy*dz;
xp=1.0;
for m=1:NumberOfZSteps
for n=1:NumberOfYSteps
yp=ymin+0.5*dy+(n-1)*dy;
zp=zmin+0.5*dz+(m-1)*dz;
Rp=[xp yp zp];
B=[0 0 0];
for i=1:Number_of_Segments
C=end1+(i-1)*dL+0.5*dL;
R=Rp-C;
norm_R=norm(R);
R_Hat=R/norm_R;
dH=(I/(4*pi*norm_R*norm_R))*cross(dL,R_Hat);
B=B+mu*dH;
end
dflux=dS*dot(B,aN);
flux=flux+dflux;
end
end
M=flux/I
end


Copyright © 2013-2018

javascrapbook.com is a computer science content service should not be treated as the publisher or speaker of any information provided by another Computer Science content provider.

Contact email: help@javascrapbook.com