In MATLAB, when using the coeffs function on a polynomial like f = 2x^2 + 1, it only returns the non-zero coefficients, resulting in [2, 1]. To include zero coefficients in the output, the polynomial must be explicitly defined with all terms, such as f = 2x^2 + 0x + 1. This ensures that MATLAB recognizes the zero coefficient for the x term. Alternatively, starting with a coefficient array like f = [2, 0, 1] can also achieve the desired output. The discussion highlights the importance of explicitly stating all coefficients in polynomial expressions to ensure accurate representation in MATLAB.