0% found this document useful (0 votes)
13 views3 pages

MatlabHelmholtzCoil@ D 2R For One Point Allcoil

Uploaded by

jeffrey075215001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

MatlabHelmholtzCoil@ D 2R For One Point Allcoil

Uploaded by

jeffrey075215001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

% Constants

u=4*pi*10^(-7); I=5; R=0.72; d=2*R; N=65;

% Coordinates of the point where we want to calculate the magnetic field


x = 0;
y = 0;
z = 0;

% Number of segments to approximate the circular loop


numSegments = 1000;
dphi = 2 * pi / numSegments;
phi = 0:dphi:2*pi;

% Coordinates of differential elements on the loop 1


Rx1 = R * cos(phi);
Ry1 = R * sin(phi);
Rz1 = -d/2 * ones(size(phi));

% Coordinates of differential elements on the loop 2


Rx2 = R * cos(phi);
Ry2 = R * sin(phi);
Rz2 = d/2 * ones(size(phi));

% Coordinates of differential elements on the loop 3


Rx3 =-d/2 * ones(size(phi));
Ry3 = R * cos(phi);
Rz3 = R * sin(phi);

% Coordinates of differential elements on the loop 4


Rx4 = d/2 * ones(size(phi));
Ry4 = R * cos(phi);
Rz4 = R * sin(phi);

% Coordinates of differential elements on the loop 5


Rx5 = R * sin(phi);
Ry5 =-d/2 * ones(size(phi));
Rz5 = R * cos(phi);

% Coordinates of differential elements on the loop 6


Rx6 = R * sin(phi);
Ry6 = d/2 * ones(size(phi));
Rz6 = R * cos(phi);

% dL12
dlx12=-R * dphi * sin(phi);
dly12= R * dphi * cos(phi);
dlz12= zeros(size(dphi));

% dL34
dlx34=zeros(size(dphi));
dly34= -R * dphi * sin(phi);
dlz34= R * dphi * cos(phi);

% dL56
dlx56= R * dphi * cos(phi);
dly56= zeros(size(dphi));
dlz56=-R * dphi * sin(phi);
% r for loop 1
rx1= x-Rx1;
ry1= y-Ry1;
rz1= z-Rz1;
r1= sqrt(rx1.^2 + ry1.^2 + rz1.^2);

% r for loop 2
rx2= x-Rx2;
ry2= y-Ry2;
rz2= z-Rz2;
r2= sqrt(rx2.^2 + ry2.^2 + rz2.^2);

% r for loop 3
rx3= x-Rx3;
ry3= y-Ry3;
rz3= z-Rz3;
r3= sqrt(rx3.^2 + ry3.^2 + rz3.^2);

% r for loop 4
rx4= x-Rx4;
ry4= y-Ry4;
rz4= z-Rz4;
r4= sqrt(rx4.^2 + ry4.^2 + rz4.^2);

% r for loop 5
rx5= x-Rx5;
ry5= y-Ry5;
rz5= z-Rz5;
r5= sqrt(rx5.^2 + ry5.^2 + rz5.^2);

% r for loop 6
rx6= x-Rx6;
ry6= y-Ry6;
rz6= z-Rz6;
r6= sqrt(rx6.^2 + ry6.^2 + rz6.^2);

% Biot-Savart Law for loop 1


dBx1= u*I/(4*pi)*(dly12 .* rz1-dlz12 .* ry1) ./ (r1.^3);
dBy1= u*I/(4*pi)*(dlz12 .* rx1-dlx12 .* rz1) ./ (r1.^3);
dBz1= u*I/(4*pi)*(dlx12 .* ry1-dly12 .* rx1) ./ (r1.^3);

% Biot-Savart Law for loop 2


dBx2= u*I/(4*pi)*(dly12 .* rz2-dlz12 .* ry2) ./ (r2.^3);
dBy2= u*I/(4*pi)*(dlz12 .* rx2-dlx12 .* rz2) ./ (r2.^3);
dBz2= u*I/(4*pi)*(dlx12 .* ry2-dly12 .* rx2) ./ (r2.^3);

% Biot-Savart Law for loop 3


dBx3= u*I/(4*pi)*(dly34 .* rz3-dlz34 .* ry3) ./ (r3.^3);
dBy3= u*I/(4*pi)*(dlz34 .* rx3-dlx34 .* rz3) ./ (r3.^3);
dBz3= u*I/(4*pi)*(dlx34 .* ry3-dly34 .* rx3) ./ (r3.^3);

% Biot-Savart Law for loop 4


dBx4= u*I/(4*pi)*(dly34 .* rz4-dlz34 .* ry4) ./ (r4.^3);
dBy4= u*I/(4*pi)*(dlz34 .* rx4-dlx34 .* rz4) ./ (r4.^3);
dBz4= u*I/(4*pi)*(dlx34 .* ry4-dly34 .* rx4) ./ (r4.^3);

% Biot-Savart Law for loop 5


dBx5= u*I/(4*pi)*(dly56 .* rz5-dlz56 .* ry5) ./ (r5.^3);
dBy5= u*I/(4*pi)*(dlz56 .* rx5-dlx56 .* rz5) ./ (r5.^3);
dBz5= u*I/(4*pi)*(dlx56 .* ry5-dly56 .* rx5) ./ (r5.^3);

% Biot-Savart Law for loop 6


dBx6= u*I/(4*pi)*(dly56 .* rz6-dlz56 .* ry6) ./ (r6.^3);
dBy6= u*I/(4*pi)*(dlz56 .* rx6-dlx56 .* rz6) ./ (r6.^3);
dBz6= u*I/(4*pi)*(dlx56 .* ry6-dly56 .* rx6) ./ (r6.^3);

% Sum of B
Bx1 = N * sum(dBx1);
By1 = N * sum(dBy1);
Bz1 = N * sum(dBz1);

Bx2 = N * sum(dBx2);
By2 = N * sum(dBy2);
Bz2 = N * sum(dBz2);

Bx3 = N * sum(dBx3);
By3 = N * sum(dBy3);
Bz3 = N * sum(dBz3);

Bx4 = N * sum(dBx4);
By4 = N * sum(dBy4);
Bz4 = N * sum(dBz4);

Bx5 = N * sum(dBx5);
By5 = N * sum(dBy5);
Bz5 = N * sum(dBz5);

Bx6 = N * sum(dBx6);
By6 = N * sum(dBy6);
Bz6 = N * sum(dBz6);

Bx=Bx1+Bx2+Bx3+Bx4+Bx5+Bx6;
By=By1+By2+By3+By4+By5+By6;
Bz=Bz1+Bz2+Bz3+Bz4+Bz5+Bz6;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy