some matlab progamming for algorithm