怎么在matlab中实现两个因变量的数据拟合,如y=a+bx1+cx2,x1和x2已知如下列所示
x1yx25.544.815.8457142864.816.735.7342857146.737.785.8628571437.788.396.0785714298.39...
x1 y x2
5.54 4.81 5.845714286
4.81 6.73 5.734285714
6.73 7.78 5.862857143
7.78 8.39 6.078571429
8.39 6.59 6.405714286
6.59 5.67 6.454285714
5.67 5.61 6.501428571
5.61 4.97 6.511428571
4.97 5.35 6.534285714
5.35 6.4 6.337142857
6.4 5.77 6.14
5.77 4.31 5.765714286
4.31 4.68 5.44
4.68 4.48 5.298571429
4.48 5.24 5.137142857
5.24 6.06 5.175714286
6.06 5.03 5.277142857
5.03 4.8 5.081428571
4.8 4.37 4.942857143
4.37 4.54 4.951428571
4.54 5.06 4.931428571
5.06 5.44 5.014285714
5.44 6.04 5.042857143
6.04 5.63 5.04
5.63 5.546 5.125714286
5.546 5.53 5.232285714
5.53 5.306 5.398
5.306 5.304 5.507428571
5.304 4.687 5.542285714
4.687 4.598 5.434714286
4.598 4.647 5.228714286
4.647 4.38 5.088285714
4.38 4.456 4.921714286
4.456 3.899 4.768285714
3.899 3.37 4.567285714
3.37 3.739 4.291
3.739 3.702 4.155571429
3.702 3.405 4.027571429
3.405 3.165 3.850142857
3.165 2.997 3.676571429
2.997 2.847 3.468142857
2.847 3.227 3.317857143
3.227 4.764 3.297428571
4.764 4.301 3.443857143
4.301 3.79 3.529428571
3.79 3.64 3.584428571
3.64 3.62 3.652285714
3.62 3.57 3.741285714
3.57 3.52 3.844571429 展开
5.54 4.81 5.845714286
4.81 6.73 5.734285714
6.73 7.78 5.862857143
7.78 8.39 6.078571429
8.39 6.59 6.405714286
6.59 5.67 6.454285714
5.67 5.61 6.501428571
5.61 4.97 6.511428571
4.97 5.35 6.534285714
5.35 6.4 6.337142857
6.4 5.77 6.14
5.77 4.31 5.765714286
4.31 4.68 5.44
4.68 4.48 5.298571429
4.48 5.24 5.137142857
5.24 6.06 5.175714286
6.06 5.03 5.277142857
5.03 4.8 5.081428571
4.8 4.37 4.942857143
4.37 4.54 4.951428571
4.54 5.06 4.931428571
5.06 5.44 5.014285714
5.44 6.04 5.042857143
6.04 5.63 5.04
5.63 5.546 5.125714286
5.546 5.53 5.232285714
5.53 5.306 5.398
5.306 5.304 5.507428571
5.304 4.687 5.542285714
4.687 4.598 5.434714286
4.598 4.647 5.228714286
4.647 4.38 5.088285714
4.38 4.456 4.921714286
4.456 3.899 4.768285714
3.899 3.37 4.567285714
3.37 3.739 4.291
3.739 3.702 4.155571429
3.702 3.405 4.027571429
3.405 3.165 3.850142857
3.165 2.997 3.676571429
2.997 2.847 3.468142857
2.847 3.227 3.317857143
3.227 4.764 3.297428571
4.764 4.301 3.443857143
4.301 3.79 3.529428571
3.79 3.64 3.584428571
3.64 3.62 3.652285714
3.62 3.57 3.741285714
3.57 3.52 3.844571429 展开
3个回答
展开全部
使用多元回归
regress
>> X=[5.54 4.81 5.845714286
4.81 6.73 5.734285714
6.73 7.78 5.862857143
7.78 8.39 6.078571429
8.39 6.59 6.405714286
6.59 5.67 6.454285714
5.67 5.61 6.501428571
5.61 4.97 6.511428571
4.97 5.35 6.534285714
5.35 6.4 6.337142857
6.4 5.77 6.14
5.77 4.31 5.765714286
4.31 4.68 5.44
4.68 4.48 5.298571429
4.48 5.24 5.137142857
5.24 6.06 5.175714286
6.06 5.03 5.277142857
5.03 4.8 5.081428571
4.8 4.37 4.942857143
4.37 4.54 4.951428571
4.54 5.06 4.931428571
5.06 5.44 5.014285714
5.44 6.04 5.042857143
6.04 5.63 5.04
5.63 5.546 5.125714286
5.546 5.53 5.232285714
5.53 5.306 5.398
5.306 5.304 5.507428571
5.304 4.687 5.542285714
4.687 4.598 5.434714286
4.598 4.647 5.228714286
4.647 4.38 5.088285714
4.38 4.456 4.921714286
4.456 3.899 4.768285714
3.899 3.37 4.567285714
3.37 3.739 4.291
3.739 3.702 4.155571429
3.702 3.405 4.027571429
3.405 3.165 3.850142857
3.165 2.997 3.676571429
2.997 2.847 3.468142857
2.847 3.227 3.317857143
3.227 4.764 3.297428571
4.764 4.301 3.443857143
4.301 3.79 3.529428571
3.79 3.64 3.584428571
3.64 3.62 3.652285714
3.62 3.57 3.741285714
3.57 3.52 3.844571429];
y=X(:,2);
x=[ones(length(y),1) X(:,1) X(:,3)];
[B,BINT,R,RINT,STATS] = regress(y,x)
B =
0.3103
0.6965
0.2250
BINT =
-0.6930 1.3135
0.4284 0.9645
-0.1035 0.5536
R =
-0.6741
1.7794
1.4632
1.2934
-1.0051
-0.6824
-0.1122
-0.7127
0.1079
0.9376
-0.3793
-1.3163
0.1438
-0.2820
0.6536
0.9356
-0.6883
-0.1569
-0.3956
0.0720
0.4781
0.4773
0.8062
-0.0210
0.1612
0.1797
-0.0704
0.0590
-0.5645
-0.1996
-0.0422
-0.3117
-0.0123
-0.5877
-0.6836
0.1161
-0.1475
-0.3899
-0.3831
-0.3449
-0.3310
0.1873
1.4642
-0.1022
-0.3100
-0.1165
-0.0473
-0.1034
-0.1418
RINT =
-1.9611 0.6128
0.6060 2.9527
0.2678 2.6587
0.1632 2.4236
-2.1091 0.0990
-1.9448 0.5801
-1.3782 1.1537
-1.9575 0.5321
-1.1117 1.3275
-0.2977 2.1729
-1.6637 0.9051
-2.5599 -0.0727
-1.1394 1.4270
-1.5861 1.0220
-0.6384 1.9455
-0.3472 2.2183
-1.9613 0.5846
-1.4706 1.1567
-1.7050 0.9138
-1.2369 1.3809
-0.8269 1.7831
-0.8288 1.7833
-0.4781 2.0905
-1.2995 1.2574
-1.1409 1.4634
-1.1273 1.4868
-1.3804 1.2395
-1.2514 1.3694
-1.8633 0.7343
-1.4995 1.1004
-1.3492 1.2647
-1.6204 0.9969
-1.3223 1.2977
-1.8889 0.7135
-1.9711 0.6040
-1.1727 1.4048
-1.4485 1.1535
-1.6841 0.9044
-1.6699 0.9036
-1.6245 0.9347
-1.6026 0.9406
-1.0793 1.4539
0.2718 2.6567
-1.3208 1.1165
-1.5668 0.9469
-1.3980 1.1650
-1.3345 1.2400
-1.3941 1.1874
-1.4352 1.1516
STATS =
0.7099 56.2840 0.0000 0.4261
regress
>> X=[5.54 4.81 5.845714286
4.81 6.73 5.734285714
6.73 7.78 5.862857143
7.78 8.39 6.078571429
8.39 6.59 6.405714286
6.59 5.67 6.454285714
5.67 5.61 6.501428571
5.61 4.97 6.511428571
4.97 5.35 6.534285714
5.35 6.4 6.337142857
6.4 5.77 6.14
5.77 4.31 5.765714286
4.31 4.68 5.44
4.68 4.48 5.298571429
4.48 5.24 5.137142857
5.24 6.06 5.175714286
6.06 5.03 5.277142857
5.03 4.8 5.081428571
4.8 4.37 4.942857143
4.37 4.54 4.951428571
4.54 5.06 4.931428571
5.06 5.44 5.014285714
5.44 6.04 5.042857143
6.04 5.63 5.04
5.63 5.546 5.125714286
5.546 5.53 5.232285714
5.53 5.306 5.398
5.306 5.304 5.507428571
5.304 4.687 5.542285714
4.687 4.598 5.434714286
4.598 4.647 5.228714286
4.647 4.38 5.088285714
4.38 4.456 4.921714286
4.456 3.899 4.768285714
3.899 3.37 4.567285714
3.37 3.739 4.291
3.739 3.702 4.155571429
3.702 3.405 4.027571429
3.405 3.165 3.850142857
3.165 2.997 3.676571429
2.997 2.847 3.468142857
2.847 3.227 3.317857143
3.227 4.764 3.297428571
4.764 4.301 3.443857143
4.301 3.79 3.529428571
3.79 3.64 3.584428571
3.64 3.62 3.652285714
3.62 3.57 3.741285714
3.57 3.52 3.844571429];
y=X(:,2);
x=[ones(length(y),1) X(:,1) X(:,3)];
[B,BINT,R,RINT,STATS] = regress(y,x)
B =
0.3103
0.6965
0.2250
BINT =
-0.6930 1.3135
0.4284 0.9645
-0.1035 0.5536
R =
-0.6741
1.7794
1.4632
1.2934
-1.0051
-0.6824
-0.1122
-0.7127
0.1079
0.9376
-0.3793
-1.3163
0.1438
-0.2820
0.6536
0.9356
-0.6883
-0.1569
-0.3956
0.0720
0.4781
0.4773
0.8062
-0.0210
0.1612
0.1797
-0.0704
0.0590
-0.5645
-0.1996
-0.0422
-0.3117
-0.0123
-0.5877
-0.6836
0.1161
-0.1475
-0.3899
-0.3831
-0.3449
-0.3310
0.1873
1.4642
-0.1022
-0.3100
-0.1165
-0.0473
-0.1034
-0.1418
RINT =
-1.9611 0.6128
0.6060 2.9527
0.2678 2.6587
0.1632 2.4236
-2.1091 0.0990
-1.9448 0.5801
-1.3782 1.1537
-1.9575 0.5321
-1.1117 1.3275
-0.2977 2.1729
-1.6637 0.9051
-2.5599 -0.0727
-1.1394 1.4270
-1.5861 1.0220
-0.6384 1.9455
-0.3472 2.2183
-1.9613 0.5846
-1.4706 1.1567
-1.7050 0.9138
-1.2369 1.3809
-0.8269 1.7831
-0.8288 1.7833
-0.4781 2.0905
-1.2995 1.2574
-1.1409 1.4634
-1.1273 1.4868
-1.3804 1.2395
-1.2514 1.3694
-1.8633 0.7343
-1.4995 1.1004
-1.3492 1.2647
-1.6204 0.9969
-1.3223 1.2977
-1.8889 0.7135
-1.9711 0.6040
-1.1727 1.4048
-1.4485 1.1535
-1.6841 0.9044
-1.6699 0.9036
-1.6245 0.9347
-1.6026 0.9406
-1.0793 1.4539
0.2718 2.6567
-1.3208 1.1165
-1.5668 0.9469
-1.3980 1.1650
-1.3345 1.2400
-1.3941 1.1874
-1.4352 1.1516
STATS =
0.7099 56.2840 0.0000 0.4261
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询