|
直接A\B即可! :@)
from matlab help :
If A is an m-by-n matrix with m ~= n and B is a column vector with m components, or a matrix with several such columns, then X = A\B is the solution in the least squares sense to the under- or overdetermined system of equations AX = B.
还有LZ的写法, 值得精进, 数值算法忘了精光, 仅就编程说说
u1=sum(A')'; %for i=1:10, u1(i)=sum(A(i,:)); end; u1=u1';
u2=sum(A)'; %for j=1:100, u2(j)=sum(A(:,j)); end; u2=u2';
u3=((B./u1)'*A)'; %for i=1:10, A1(i,:)= A(i,:)*B(i)/u1(i); end
%for j=1:100, u3(j)= sum(A1(:,j)); end; u3=u3';
x=u3./u2; %for j=1:100, x(j)= u3(j)/(u2(j)+eps); end |
|