Matlab中出现Error using ==> .*程序下:n=2;X=[1,2,3,4,5];Y=[4,4,5,6,8,8.5];W=[2,1,3,1,1];N=length(X);A=(X'*ones(1,n)).^(ones(N,1)*(0:1:n-1));b=Y;AA=A'*(A.*(W'*(ones(1,n))))Ab=A'*(b'.*W')C=AA^(-1)*Abt=X(1)-0.1*(X(N)-X(1)):0.1:X(N)+0.1*(X(N)-X(1)
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 23:51:27
Matlab中出现Error using ==> .*程序下:n=2;X=[1,2,3,4,5];Y=[4,4,5,6,8,8.5];W=[2,1,3,1,1];N=length(X);A=(X'*ones(1,n)).^(ones(N,1)*(0:1:n-1));b=Y;AA=A'*(A.*(W'*(ones(1,n))))Ab=A'*(b'.*W')C=AA^(-1)*Abt=X(1)-0.1*(X(N)-X(1)):0.1:X(N)+0.1*(X(N)-X(1)
Matlab中出现Error using ==> .*
程序下:
n=2;
X=[1,2,3,4,5];
Y=[4,4,5,6,8,8.5];
W=[2,1,3,1,1];
N=length(X);
A=(X'*ones(1,n)).^(ones(N,1)*(0:1:n-1));
b=Y;
AA=A'*(A.*(W'*(ones(1,n))))
Ab=A'*(b'.*W')
C=AA^(-1)*Ab
t=X(1)-0.1*(X(N)-X(1)):0.1:X(N)+0.1*(X(N)-X(1));
plot(X,Y,'p',t,polyval([C(2),C(1)],t));grid;
Matlab中出现Error using ==> .*程序下:n=2;X=[1,2,3,4,5];Y=[4,4,5,6,8,8.5];W=[2,1,3,1,1];N=length(X);A=(X'*ones(1,n)).^(ones(N,1)*(0:1:n-1));b=Y;AA=A'*(A.*(W'*(ones(1,n))))Ab=A'*(b'.*W')C=AA^(-1)*Abt=X(1)-0.1*(X(N)-X(1)):0.1:X(N)+0.1*(X(N)-X(1)
你的b是一个6维矩阵,前后都是5维度的.不能相乘
Ab=A'*(b'.*W') 出错