some algorithm written in matlab