帮我看看 AX=B?
A是10X100维X是100X1维 B是10X1维, 然后计算 Xfor i=1:10,u1(i)= sum(A(i,:)); end
u1=u1';
for j=1:100,u2(j)= sum(A(:,j)); end
u2=u2';
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';
for j=1:100, x(j)= u3(j)/(u2(j)+eps); end
或者有更好的方法吗~~ 帮偶看看:@(
[ 本帖最后由 ChaChing 于 2010-4-10 20:33 编辑 ] 直接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
页:
[1]