linest
Linear regression coefficients (with optional statistics).
Syntax
Section titled “Syntax”v = linest(knownys, knownxs, const, stat)Description
Section titled “Description”Returns the slope and intercept of the least-squares fit — [slope, intercept]. With const = false, forces the intercept to zero. With stat = true, returns an array including standard errors, R², F-statistic, and degrees of freedom.
Example
Section titled “Example”linest([2 4 6 8], [1 2 3 4]) % [2 0] slope, intercept