bmc matlab code