Bloch Equation Simulator

Brian Hargreaves


This is a simple, yet useful Bloch equation simulator that runs in Matlab. It is written as a MEX function so that it can run reasonably quickly, and simulate RF and a 1D gradient waveform. Simulations can be run for a range of spatial offsets and frequency offsets.

Sample Application

As an example, consider the RF and gradient shown in Figure 1 below. If these are simulated over a frequency range [-200,200Hz] and a spatial range [-2,2cm], the resulting signal is shown by the image in Figure 2.

Figure 1.
Sample RF and Gradient waveforms that are simulated using this simulation.

Figure 2.
Result of simulation. Signal intensity as a function of space and position.
Click on Figures to Enlarge


The following files are available:

Example Code

  1. ssfptransient.m uses mex function to efficiently plot SSFP transients as a function of frequency. (Requires magphase.m)
  2. timehist.m calculates M(t,r,f) and plots for a specific position and frequency.


Please report comments/bugs with this code to Brian Hargreaves.