I created a tokamak fusion reactor simulation in Matlab as part of a project at university. The two code samples I attached are a simulation of a nuclear fusion reactor. Just like the one in the Culham Centre for Fusion Energy in the UK. It demonstrates how charged high-energy particles can be held in one magnetic bottle (the Tokamak), without touching its walls and melting it. The charged particles are held together by a magnetic field produced by current coils and a rotating charged plasma cloud. The magnetic field has a very complicated shape, as it is created by multiple current coils and a rotating charged plasma cloud. The calculation of the magnetic field was performed algebraically, which significantly increased the speed and precision of the simulation.