Translation layer from MATLAB to R
