开发者

matlab: sparse matrix decomposition

I am a beginner to matlab. I have a sample code. I want to understand 开发者_C百科what is happening with the piece of code snippet.

Sample.m

n=60;%Number of division of length
m=84;%Number of division of time
N=2*m*n+m+n;
A=spalloc(N,N,4*N);
// A is a Matrix
for j=1:m
 if(massdot(j)>=0)
 i=1:n;
A(((n+1)*(j-1)+i+1-1)*N+(n+1)*(j-1)+i+1)=Nuf(:,j).*kfn(:,j)*as*Ac./((1+Bi(:,j)/5)*   (2*Dh))+n*massdot(j)*cfn(:,j)/L;
A(((n+1)*(j-1)+i-1+1-1)*N+(n+1)*(j-1)+i+1)=Nuf(:,j).*kfn(:,j)*as*Ac./((1+Bi(:,j)/5)*(2*Dh))-n*massdot(j)*cfn(:,j)/L;
A(((n+1)*m+n*j+i-1)*N+(n+1)*(j-1)+i+1)=-Nuf(:,j).*kfn(:,j)*as*Ac./((1+Bi(:,j)/5)*(2*Dh));
A(((n+1)*m+n*(j-1)+i-1)*N+(n+1)*(j-1)+i+1)=-Nuf(:,j).*kfn(:,j)*as*Ac./((1+Bi(:,j)/5)*(2*Dh));
B((n+1)*(j-1)+i+1,1)=abs(ff(:,j).*massdot(j)^3/(2*pf^2*Ac^2*Dh)); %Viscous dissipation
i=0;
A((n+1)*(j-1)+i+1,(n+1)*(j-1)+i+1)=1;
B((n+1)*(j-1)+i+1,1)=TH;
...
X=A\B;
for j=1:m
i=0:n;
Tf(:,j)=full(X((n+1)*(j-1)+i+1));
...

Just explain me, whats happening with lines 9, 10, 11 & 12. especially expression left side to =. which is inside the ( ).

Edit:

Updated code. am trying to find out Tf Matrix. I cannot share entire code, since it is my confidential project's code.


Basically, you set the value of n elements of A to something. The index (that long calculation between braces) to A is a vector, because in it's calculation you use i, which is a vector of all the elements from 1 to n.

It's hard to say more without having some background information as to what the code is supposed to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜