询问MATLAB程序cleark=3;x=xlsread('2000.xls')[n,m]=size(x);%-----------弦长参数化--------------------------------------u(k+n)=0;for i=1:n-1u(k+i+1)=u(k+i)+sqrt((x(i+1,1)-x(i,1))^2+(x(i+1,2)-x(i,2))^2);end;L=u(n+k);for i=1:nu(k+i)=u(k+i)/L;end
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/23 13:27:23
询问MATLAB程序cleark=3;x=xlsread('2000.xls')[n,m]=size(x);%-----------弦长参数化--------------------------------------u(k+n)=0;for i=1:n-1u(k+i+1)=u(k+i)+sqrt((x(i+1,1)-x(i,1))^2+(x(i+1,2)-x(i,2))^2);end;L=u(n+k);for i=1:nu(k+i)=u(k+i)/L;end
询问MATLAB程序
clear
k=3;
x=xlsread('2000.xls')
[n,m]=size(x);
%-----------弦长参数化--------------------------------------
u(k+n)=0;
for i=1:n-1
u(k+i+1)=u(k+i)+sqrt((x(i+1,1)-x(i,1))^2+(x(i+1,2)-x(i,2))^2);
end;
L=u(n+k);
for i=1:n
u(k+i)=u(k+i)/L;
end;
for i=1:3
u(k+i+n)=1;
end
%控制多边线
plot(x(:,1),x(:,2),'o');
hold on
A=zeros(n+2);
A(1,1)=1;A(1,2)=-1;
A(2,2)=1;
A(n+2,n+1)=-1;A(n+2,n+2)=1;
A(n+1,n+1)=1;
for i=3:n
for j=0:2
A(i,i+j-1)=Base(i+j-1,k,u,u(i+2));
end
end
%e:方程右边.
e=0;
for i=1:m
e(n+2,i)=0;
end
for i=1:n
e(i+1,:)=x(i,:);
end
%求出控制点d
d=inv(A)*e;
plot(d(:,1),d(:,2),'g');
hold on
错误提示为:
Warning:Matrix is singular to working precision.
xls中的数据为110*109的矩阵
询问MATLAB程序cleark=3;x=xlsread('2000.xls')[n,m]=size(x);%-----------弦长参数化--------------------------------------u(k+n)=0;for i=1:n-1u(k+i+1)=u(k+i)+sqrt((x(i+1,1)-x(i,1))^2+(x(i+1,2)-x(i,2))^2);end;L=u(n+k);for i=1:nu(k+i)=u(k+i)/L;end
在求矩阵的逆时,必须保证矩阵非奇异,即det(A)不等于零.现在提示的错误是矩阵是奇异的,即det(A)等于零.这不是程序问题,请检查你的数据.