ARMPS code written in MATLAB