first version of an existing matlab code ported to julia