Magnetic fields of solenoids and magnets

Analytical calculation of the magnetic field of finite solenoids (which is also the field of cylindrical magnets) and cuboidal magnets
2,2K download
Aggiornato 25 set 2025

Visualizza la licenza

1) The file 'FieldBar.m' calculates the cuboidal magnet field with the formulas of Camacho & Sosa, Rev. Mex. E, E 59, 8-17, 2013 (see http://www.scielo.org.mx/pdf/rmfe/v59n1/v59n1a2.pdf), which have been corrected (see the documentation).
2) The file 'FieldSolenoid.m' calculates the cylindrical magnet (=solenoid) field with (corrected) formula of Callaghan & Maslen (1960) and Derby & Olbert, Am. J. Phys. 78, 229 , 2010 (see respectively https://archive.org/details/nasa_techdoc_19980227402 and https://doi.org/10.1119/1.3256157). See details in the documentation.
3) The file 'PlotField.m' plot the magnetic field in various cases, for cylindrical magnets (=solenoids) and cuboidal magnets.
WARNING/REQUIREMENT: the included files whose name start with 'Elliptic' calculate the needed elliptic integrals (these files are actually the functions I have released at https://fr.mathworks.com/matlabcentral/fileexchange/51989-maple-elliptic-integrals), by relying on 'Elliptic_Integrals.zip' by Thomas Hoffend, which has to be downloaded at https://fr.mathworks.com/matlabcentral/fileexchange/3705-elliptic_integrals-zip
[Alternatively, 'Elliptic Integrals' by Moiseev Igor (https://fr.mathworks.com/matlabcentral/fileexchange/8805-elliptic-integrals-and-functions?s_tid=srchtitle) can be used by commenting/uncommenting 2 lines in the files whose name start with 'Elliptic']

Cita come

David CEBRON (2025). Magnetic fields of solenoids and magnets (https://it.mathworks.com/matlabcentral/fileexchange/71881-magnetic-fields-of-solenoids-and-magnets), MATLAB Central File Exchange. Recuperato .

Cébron, David. Analytical Magnetic Fields of Cylindrical & Cuboidal Magnets. 2021, https://doi.org/10.5281/ZENODO.15081750.

Visualizza più stili
Compatibilità della release di MATLAB
Creato con R2019a
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Categorie
Scopri di più su State-Space Control Design and Estimation in Help Center e MATLAB Answers
Riconoscimenti

Ispirato da: Elliptic_Integrals.zip

Ispirato: Magnetic Field Modeling

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versione Pubblicato Note della release
1.1

Zenodo source and DOI reference added

1.0.4

Small misprint in the documentation

1.0.3

Thanks to Max Oberländer : correction of an error present in the formula of Camacho & Sosa (2013), on which my script relies for cuboidal magnets. See details in the enclosed documentation.

1.0.2

Only changed the picture

1.0.1

Documentation added (with details on the analytical expressions used).

1.0.0