最小二乘法拟合曲面。
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
代码如下
x=[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8];
x2=x.^2;
y=[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6];
y2=y.^2;
z=[0.85 0.85 0.85 0.861 0.87 0.885 0.893 0.925 0.948 0.971 0.993 1.016 1.035 1.062 1.085 1.106 1.13 1.148
0.855 0.855 0.855 0.864 0.874 0.888 0.907 0.93 0.954 0.977 1.001 1.026 1.05 1.074 1.096 1.12 1.142 1.159
0.864 0.864 0.864 0.868 0.879 0.884 0.913 0.936 0.961 0.986 1.011 1.037 1.061 1.085 1.11 1.132 1.152 1.169
0.873 0.873 0.873 0.874 0.885 0.901 0.92 0.945 0.969 0.995 1.021 1.047 1.072 1.097 1.122 1.144 1.163 1.18
0.882 0.882 0.882 0.883 0.894 0.908 0.929 0.959 0.978 1.005 1.022 1.057 1.083 1.109 1.133 1.154 1.173 1.188
0.892 0.892 0.892 0.894 0.904 0.92 0.941 0.964 0.99 1.016 1.043 1.067 1.094 1.12 1.143 1.164 1.182 1.196
0.901 0.901 0.901 0.906 0.916 0.93 0.952 0.975 1 1.026 1.052 1.077 1.104 1.129 1.152 1.171 1.188 1.203
0.911 0.911 0.911 0.916 0.926 0.942 0.962 0.985 1.01 1.036 1.062 1.086 1.112 1.136 1.158 1.176 1.194 1.209
0.921 0.921 0.921 0.928 0.935 0.952 0.972 0.996 1.021 1.046 1.072 1.096 1.12 1.143 1.163 1.181 1.199 1.214
0.929 0.929 0.931 0.936 0.946 0.962 0.982 1.006 1.031 1.056 1.081 1.106 1.128 1.15 1.169 1.187 1.204 1.22
0.935 0.937 0.94 0.946 0.956 0.972 0.993 1.017 1.042 1.066 1.092 1.116 1.138 1.159 1.177 1.195 1.212 1.228
0.941 0.944 0.949 0.956 0.966 0.982 1.004 1.028 1.053 1.077 1.103 1.126 1.148 1.168 1.186 1.204 1.222 1.237
0.946 0.951 0.957 0.966 0.977 0.993 1.016 1.04 1.063 1.089 1.114 1.136 1.158 1.178 1.196 1.214 1.232 1.25
0.953 0.959 0.967 0.975 0.986 1.005 1.028 1.05 1.075 1.101 1.124 1.147 1.168 1.187 1.206 1.224 1.244 1.266
0.961 0.988 0.975 0.984 0.997 1.018 1.04 1.061 1.086 1.111 1.134 1.156 1.176 1.196 1.215 1.235 1.258 1.277
0.972 0.978 0.985 0.994 1.01 1.03 1.05 1.073 1.096 1.119 1.142 1.164 1.184 1.204 1.224 1.245 1.268 1.289
];
n=length(x); X=[x2 y2 ones(n,1)];
a = regress(z,X);
c=a(3);
b=a(2);
a=a(1);
错误显示
错误使用 horzcat
串联的矩阵的维度不一致。
出错 zxecfnh (line 22)
n=length(x); X=[x2 y2 ones(n,1)];
求大神解答~
0 commentaires
Réponse acceptée
sedor
le 17 Nov 2022
也许可用下列模型拟合(y=y-.8):
fx=(b(1)+b(2)*x1+b(3)*x2+b(4)*x1.^2+b(5)*x2.^2+b(6)*x1.*x2+b(7)*x1.^3+b(8)*x2.^3+b(9)*x1.*x2.^2+b(10)*x1.^2.*x2)./(1+b(11)*x1+b(12)*x2+b(13)*x1.^2+b(14)*x2.^2);
b =[0.04592294559 -0.03901414484 0.068398893 0.09567766717 -0.04613171904 -0.1331041884 0.1423630308 0.03154915609 0.06671164437 0.06088959563 -0.8034532625 -0.6256762205 1.066828227 0.3648534856]
RSS = 0.0028752156241
MSe = 1.0493e-05
R^2 = 0.99922
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Mathematics and Optimization dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!