这样写为什么会报错呢。

2 visualizzazioni (ultimi 30 giorni)
dutoga
dutoga il 28 Ott 2022
Risposto: 埃博拉酱 il 7 Nov 2024 alle 0:33
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;这样反而不会出错

Risposte (1)

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

Categorie

Scopri di più su Big Data Processing in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!