# rsequence.m

R-sequences described in Malcolm Levitt's review (https://doi.org/10.1002/9780470034590.emrstm0551). The notation below is based on RN_{n}^{\nu}.

## Syntax

    [phases,pulse_amp,pulse_dur]=rsequence(n_rotor_periods,n_blocks_per_period,...
phase_factor,n_cycle_repeats,mas_rate,...
element_type,supercycle_type)


## Arguments

  n_rotor_periods     -  "small n" symmetry number, gives number of
rotor periods required in the R symmetry

n_blocks_per_period -  "capital n" symmetry number, gives the number of
R elements contained within the R symmetry

phase_factor        -  "nu" to calculate the alternating phase in the
R sequence:

180*nu/N = 180*phase_factor/n_blocks_per_period

n_cycle_repeats     -  number of times the full R sequence is applied

mas_rate            -  rotor spinning rate, Hz

element_type        -  R element needs to be an inversion pulse. Common
R elements are:

'180_pulse'   : simple inversion pulse

'90270_pulse' : composite inversion pulse

supercycle_type     -  The R sequence can be repeated multiple
times in combination with supercycles, for
improved performance, removal of undesired
higher order terms. If the he unmodified R
is denoted [phase], this can either be in-
verted, [-phase], or have an overall phase

Common supercycles are:

'hetero_single_quantum'
[phase]_0:[-phase]_0:[phase]_120:[-phase]_120:[phase]_240:[-phase]_240

'homo_double_quantum_nucycle'
[phase]_0:[-phase]_0

'homo_double_quantum_nupicycle'
[phase]_0:[-phase]_0:[-phase]_180:[phase]_180


## Outputs

  phases    - the sequence of pulse phases, radians

pulse_amp - RF nutation frequency in rad/s, a scalar because
R-sequences are phase-modulated

pulse_dur - duration of the pulses in the sequence element,
a vector with the length matching the number of
pulses in the sequence element (seconds)