plot a magnetic field around a 10 turns coil eith 1a current flowing in matlab

main.m
% Number of turns in the coil
N = 10;

% Current flowing through the coil in Amperes
I = 1;

% Radius of the coil in meters
R = 1; 

% Permeability of free space in H/m
u_0 = 4*pi*10^-7;

% Magnetic field calculation at a distance r from the center of the coil
r = linspace(0, 10, 100);
B = (u_0 * N * I * R^2) ./ (2 * (R^2 + r.^2).^(3/2));

% Plotting the magnetic field
plot(r, B);
xlabel('Distance from the center of the coil (m)');
ylabel('Magnetic Field (Tesla)');
title('Magnetic Field around a 10-turn Coil with 1A current flowing');
541 chars
22 lines

You can run this code in MATLAB to plot the magnetic field around a 10-turn coil with a 1A current flowing.

related categories

gistlibby LogSnag