One form of ridge regression is the problem:
minimize |Ax - b|, and keep x near a given point x0 (often 0).
If we cast this as:
minimize |Ax - b|^2 + w^2 |x - x0|^2 ,
we can solve it by running least squares on these extended inputs:
[ A ] [ b ]
[ w I ] [ w x0 ]
Here w is a weight factor that balances minimizing |Ax - b|, and keeping x near x0.
How should one choose it if one has no idea ?
A rule of thumb is to make |Ax - b| and |x - x0| roughly equal -- print those values.
Added:
Weighted least squares,
with different weights w$_i$, is a powerful method.
For example, w$_i \sim \tfrac{1}{|\text{x}_i|}$$_i \sim \frac{1}{\sqrt |\text{x}_i|}$
pushes small x$_i$ towards 0 (think iPhone fingers), "sparsifies" —
a poor man's approach to L1-norm regularization,regularization;
see LASSO.
Not Matlab, but hope this helps.