フィルターのクリア

Polyfit with centering and scaling values

7 ビュー (過去 30 日間)
Raj Raj
Raj Raj 2014 年 10 月 3 日
コメント済み: Raj Raj 2014 年 10 月 3 日
Hi All,
I want to output centering and scaling values from the command prompt.
Here is the sample data I took from the matlab help:
x = (0: 0.1: 2.5)';
y = erf(x);
When I tried polyfit command here is the result:
ppp = polyfit(x,y,3)
ppp =
9.284046212199847e-02 -6.231661786330390e-01 1.384345932284717e+00 -1.993673645226568e-02
Second trial with centering and scaling values as output requests gives
>> [ppp1,SSS,muu]= polyfit(x,y, 3)
ppp1 =
4.154044003296898e-02 -1.608834507201939e-01 2.001009389523068e-01 9.181275523715360e-01
SSS =
R: [4x4 double]
df: 22
normr: 3.578557910406126e-02
muu =
1.250000000000000e+00
7.648529270389177e-01
I just don't understand why the ppp is differing from ppp1.
Please let me know the mistake in my understanding... Thanks for your time.

採用された回答

Mohammad Abouali
Mohammad Abouali 2014 年 10 月 3 日
because ppp fits y to x
but ppp1 fits y to x^ where x^ = (x-mu1)./mu2;
check this code:
x = (0: 0.1: 2.5)';
y = erf(x);
ppp = polyfit(x,y,3)
ppp =
0.0928 -0.6232 1.3843 -0.0199
[ppp1,SSS,muu]= polyfit(x,y, 3)
ppp1 =
0.0415 -0.1609 0.2001 0.9181
plot(x,y,'r.')
hold on
plot(x,polyval(ppp,x))
plot(x,polyval(ppp1,x),'k')
plot(x,polyval(ppp1,(x-muu(1))./muu(2)),'g')
legend('Data','ppp','polyval(ppp1,x)','polyval(ppp1,(x-muu(1))./muu(2))');
  1 件のコメント
Raj Raj
Raj Raj 2014 年 10 月 3 日
Got it. Thanks Mr. Mohammad..

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeClassification についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by