这样写为什么会报错呢。

1 view (last 30 days)
dutoga
dutoga on 28 Oct 2022
Answered: 埃博拉酱 on 7 Nov 2024
clc
clear
syms a1 a2 a3 a4 a5 x y r;
r=[0.0349 0.0355 0.0322 0.0307 0.02880.0263 0.0256 0.0254 0.0248 0.0239 0.0209 0.0201 0.0188 0.0184 0.0167 0.01350.0132 0.0102 0.0070 0.0058 0.0034 0.0015 0 -0.0015 -0.0034 -0.0057 -0.0078-0.0087 -0.0107 -0.0126 -0.0136 -0.0150 -0.0165 -0.0173 -0.0183 -0.0198 -0.0206-0.0230 -0.0256 -0.0256 -0.0288 -0.0303 -0.0324 -0.0347 -0.0342];
z=a1*x+a2*y+a3*x^2+a4*y^2+a5*x*y;
s= sum((r-z)^2);
ds_da1=diff(s,a1)
ds_da2=diff(s,a2)
ds_da3=diff(s,a3)
ds_da4=diff(s,a4)
ds_da5=diff(s,a5)
s= sum(r-z)^2;这样反而不会出错

Answers (1)

埃博拉酱
埃博拉酱 on 7 Nov 2024
^是矩阵幂运算,.^是向量化幂运算,你混淆了这两种运算符

Tags

Community Treasure Hunt

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

Start Hunting!