How can I transform this matlab code into Julia

Not for a long time PSA: replacement of ind2sub/sub2ind in Julia 0.7+