MATLAB: Ampere’s Law

ampere's lawmagneticMATLAB

I want to find magnetic field generated by infinitly long wire using ampere's law but ampere's law is gives us scaler how can i get vectorial solutions
ampere's law : u0*i/(2*pi*d)

Best Answer

You may not have the definition of it that you need.
Try this:
mu0 = pi*4E-7; % Ref: https://en.wikipedia.org/wiki/Vacuum_permeability
AmpereB = @(m0u,I,r) (mu0.*I)./(2*pi*r); % µₒ = Magnetic Constant, I = Current (A), r = radius (m), Ref: https://en.wikipedia.org/wiki/Amp%C3%A8re%27s_circuital_law
radius = linspace(1E-3, 1);
I = 1;
figure(1)
semilogy(radius, AmpereB(mu0,I,radius))
grid
xlabel('r (m)')
ylabel('B')