From: Bruce Bowler on
On Thu, 22 Apr 2010 13:03:05 +0000, Konrad set fingers to keyboard and
typed:

> Hi John,
>
> I've downloaded your function, but don't see how I get R² out of it.
> Could you please indicate how it is done?
>
> Best wishes,
> Konrad

I'm not John, but, from reading the help,

The output is a structure. One of the items in the structure is R2 which
is the r^2 of the fit.

Bruce
From: John D'Errico on
"Konrad " <Konrad.Lehmann(a)uni-jena.de> wrote in message <hqphe9$5om$1(a)fred.mathworks.com>...
> Hi John,
>
> I've downloaded your function, but don't see how I get R² out of it. Could you please indicate how it is done?
>

Read the help. Our just look at the output.

P = polyfitn(x,y,1)
P =
ModelTerms: [2x1 double]
Coefficients: [4.7555 -16.228]
ParameterVar: [0.041696 0.79748]
ParameterStd: [0.2042 0.89302]
R2: 0.99268
RMSE: 0.14613
VarNames: {}

P.R2
ans =
0.99268

John
From: Konrad on
Thanks, my fault. I hadn't yet set the path to the new directory in the toolbox, so the function hadn't yet worked. Now, of course, it's obvious.

"John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <hqpiq0$73$1(a)fred.mathworks.com>...
> "Konrad " <Konrad.Lehmann(a)uni-jena.de> wrote in message <hqphe9$5om$1(a)fred.mathworks.com>...
> > Hi John,
> >
> > I've downloaded your function, but don't see how I get R² out of it. Could you please indicate how it is done?
> >
>
> Read the help. Our just look at the output.
>
> P = polyfitn(x,y,1)
> P =
> ModelTerms: [2x1 double]
> Coefficients: [4.7555 -16.228]
> ParameterVar: [0.041696 0.79748]
> ParameterStd: [0.2042 0.89302]
> R2: 0.99268
> RMSE: 0.14613
> VarNames: {}
>
> P.R2
> ans =
> 0.99268
>
> John