Multiple Summation of Series using For Loops (Magnetic Flux through Coil Simulation)
1 次查看(过去 30 天)
显示 更早的评论
Hello all,
I am trying to sum the following series for various positions, y being the position of the magnet in the function.
The 'r' and 'z' values are known dimensions of a coil, indicating the thickness and height of the coil respectively. I have included the values in the table below. The plot that I get from this code is incorrect and I can't figure out why. Is my methodology for executing the series summation for each value of position (y) correct? Any help would be greatly appreciated.
clearvars
clc
close all
position = -0.09:0.001:0.09;
L = length(position);
Flux = zeros(1,L);
s = 0;
r = [0.00875 0.0125]; %inner and outer radius of coil (thickness)
z = [-0.015 0.015]; % z(2)-z(1) = height of coil (30 mm), centred at 0
Ac = (r(2) - r(1))*(z(2)-z(1)); %cross-sectional area of coil
Nc = 1500; % constants from table 1
Br = 1.31;
Vm = 5e-6;
Ff = 0.33;
for y = 1:L
for ii=1:2
for jj=1:2
x1 = (-1)^(ii+jj);
Zij = sqrt(r(ii)^2 + (z(jj) - position(y))^2);
x2 = log(r(ii)+Zij);
x3 = r(ii)/Zij;
s = s + x1*(x2 - x3);
end
end
s = s * 3*Nc*Br*Vm*Ff/(2*Ac);
Flux(y) = s/2.1079; %maximum flux should be 2.1079
s = 0;
end
y_h = position/0.03;
figure
plot(y_h,Flux)
xlabel('y / h')
ylabel('Flux / Maximum Flux')
The correct plot should look like the one below.
0 个评论
采纳的回答
Daniel M
2019-11-4
Hi Samuel, I don't see anything wrong with the code. The only thing I would change is to do the following outside the loops:
Flux = Flux./max(Flux);
This will normalize it to [-1,1] properly, since the actual max doesn't seem to be 2.1079.
As for the inflection point on your plot on both sides of the center (y/h =0), it is supposed to be there. It just isn't very clear in their plot. I'm sure if you found the 2nd derivative of the equation with respect to z, you would see clear inflection points analytically.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!