The Matlab residue command performs partial fraction expansion by decomposing the ratio of two polynomials into partial fractions. It returns the residues, poles, and direct term coefficients. The residues are the coefficients of the terms with denominators of (z-pole), poles are the locations of the singularities, and the direct term contains coefficients of terms without poles. The command works for cases with real or complex poles, repeated poles, and when the numerator degree exceeds the denominator degree.