matlab中出现Undefined function or variable 'X'.请高人帮忙分析下,谢谢
functionC=ispoiy(X,Y,M)%Input-Xisthe1xnabscissavector%-Yisthe1xnordinatevector%-Misth...
function C=ispoiy(X,Y,M)
%Input -X is the 1xn abscissa vector
% -Y is the 1xn ordinate vector
% -M is the degree of the least-squares polynomial
%Output-C is the coefficient list for the polynomial
n=length(X);
B=zeros(1:M+1);
F=zeros(n:M+1);
%Fill the columns of F with the powers of X
for k=1:M+1
F(:,k)=X'.^(K-1);
end
%Solve the linear system from(25)
A=F'*F;
B=F'*Y;
C=A\B;
C=flipud(C);
一直报错
C=ispoiy(X,Y,M)
??? Undefined function or variable 'X'. 展开
%Input -X is the 1xn abscissa vector
% -Y is the 1xn ordinate vector
% -M is the degree of the least-squares polynomial
%Output-C is the coefficient list for the polynomial
n=length(X);
B=zeros(1:M+1);
F=zeros(n:M+1);
%Fill the columns of F with the powers of X
for k=1:M+1
F(:,k)=X'.^(K-1);
end
%Solve the linear system from(25)
A=F'*F;
B=F'*Y;
C=A\B;
C=flipud(C);
一直报错
C=ispoiy(X,Y,M)
??? Undefined function or variable 'X'. 展开
2个回答
展开全部
函数本身存在错误,修改后,将下面函数保存为ispoiy.m。
function C=ispoiy(X,Y,M)
%Input -X is the 1xn abscissa vector
% -Y is the 1xn ordinate vector
% -M is the degree of the least-squares polynomial
%Output-C is the coefficient list for the polynomial
n=length(X);
B=zeros(1:M+1);
F=zeros(n:M+1);
%Fill the columns of F with the powers of X
for k=1:M+1
F(:,k)=X'.^(k-1)%为小k
end
%Solve the linear system from(25)
A=F'*F;
B=F'*Y';%Y为转置
C=A\B;
C=flipud(C);
然后对X,Y,M赋值。
例如:
在命令窗口输入:
X=[1 2 3 4];Y=[4 5 6 7];M=length(X)-1;%要求X,Y维数一致,
C=ispoiy(X,Y,M)
function C=ispoiy(X,Y,M)
%Input -X is the 1xn abscissa vector
% -Y is the 1xn ordinate vector
% -M is the degree of the least-squares polynomial
%Output-C is the coefficient list for the polynomial
n=length(X);
B=zeros(1:M+1);
F=zeros(n:M+1);
%Fill the columns of F with the powers of X
for k=1:M+1
F(:,k)=X'.^(k-1)%为小k
end
%Solve the linear system from(25)
A=F'*F;
B=F'*Y';%Y为转置
C=A\B;
C=flipud(C);
然后对X,Y,M赋值。
例如:
在命令窗口输入:
X=[1 2 3 4];Y=[4 5 6 7];M=length(X)-1;%要求X,Y维数一致,
C=ispoiy(X,Y,M)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询