CD segment matlab program