第1个回答 2011-01-23
数据点太少了,用非线性回归。
x=[11.96,12.22,19.76,27.56,27.82]
y=[1.7,7.3,4.5,1.0,8.0]
fun=inline('(a(1)*sin(a(2)*x)+a(3)).*sin(a(4)*x)+a(5)','a','x')
a=nlinfit(x,y,fun,[1 2 3 4 5])
yy=(a(1)*sin(a(2)*x)+a(3)).*sin(a(4)*x)+a(5)
plot(x,y,'o-',x,yy)
结果:
a =
1.0e+003 *
-0.0119 0.0016 1.3057 0.0040 1.1299
yy =
2.7506 7.3000 2.4013 2.0523 7.9972
我找到了另一个函数,把高潮时的数据回归了一下。
A=[...
0 771
0.514583333 775
1.028472222 749
1.547916667 741
2.057638889 716
2.584027778 694
3.090972222 675
3.629861111 645
4.133333333 633
4.685416667 611
5.186805556 604
5.745138889 608
6.245833333 604
6.796527778 633
7.296527778 628
7.836805556 666
8.3375 662
8.869444444 697
9.370833333 693
9.896527778 718
10.4 715
10.92083333 729
11.42708333 723
11.94375 729
12.45138889 720
12.96458333 719
13.475 706
13.98472222 701
14.49722222 684
15.02083333 651
15.54375 626
16.04097222 623
16.57222222 593
17.06180556 593
17.61041667 562
18.09305556 562
18.66736111 543
19.14930556 538
19.73194444 555
20.22361111 544
20.78125 593
21.27777778 585
21.81805556 641
22.31875 641
22.84861111 689
23.35277778 699
23.87569444 730
24.38402778 750
24.90277778 762
24.92847222 780
25.41319444 787
26.44305556 805
26.95486111 783
27.47291667 801
27.98125 771
28.50347222 778
29.00902778 745
29.53680556 738
30.03888889 706
30.57361111 688
31.07291667 660
31.61875 640
32.11736111 614
32.67291667 609
33.17361111 583
33.73125 607
34.23333333 584
34.78055556 628
35.28402778 609
35.81805556 657
36.32361111 642
36.84791667 682
37.35694444 671
37.87430556 699
38.38472222 691
38.89722222 707
39.41041667 701
39.91875 706
40.43402778 701
40.93888889 698
41.45694444 692
41.95833333 684
42.47916667 678
42.97708333 666
43.50208333 658
43.95486111 646
44.52847222 635
45.01736111 622
45.55902778 609
46.04305556 595
46.59722222 584
47.07916667 567
47.64930556 570
48.13611111 547
48.70625 579
49.20416667 556
49.75347222 609
50.25833333 594
50.79097222 649
51.30069444 647
51.82361111 689
52.33680556 701
52.85347222 725
53.36944444 746
53.88125 751
54.40069444 776
54.90902778 764
55.43125 787
55.93680556 764
56.4625 779
56.96458333 750
57.49444444 755
57.99375 723
58.52916667 718
59.025 684
59.56597222 675];
x=A(:,1);y=A(:,2);
% f(x) = a0 + a1*cos(x*w) + b1*sin(x*w) + a2*cos(2*x*w) + b2*sin(2*x*w)
fun=inline('a(1) + a(2)*cos(x*a(3)) + a(4)*sin(x*a(3)) + a(5)*cos(2*x*a(3)) + a(6)*sin(2*x*a(3))','a','x')
%fun=inline('(a(1)*sin(a(2)*x)+a(3)).*sin(a(4)*x)+a(5)','a','x')
a=nlinfit(x,y,fun,[600 40 0.2 12 50 -60])
%yy=(a(1)*sin(a(2)*x)+a(3)).*sin(a(4)*x)+a(5);
yy=a(1) + a(2)*cos(x*a(3)) + a(4)*sin(x*a(3)) + a(5)*cos(2*x*a(3)) + a(6)*sin(2*x*a(3));
plot(x,y,'o',x,yy)