Unable to grasp the concept of Sparse Matrix - Kindly help me understand the following code.

1 view (last 30 days)
Hamza Shafiq
Hamza Shafiq on 21 Sep 2021
% Sparse Matrix Indexes: S(i,j)=0 if dF(i)/dy(j)=0, else S(i,j)=1
diagonal = diag(ones(bins,1));
dcidci = diag(ones(bins,1),0)+diag(ones(bins-1,1),-1)+diag(ones(bins-1,1),+1);
dcidcj = diag(ones(bins,1))+diag(ones(bins-1,1),-1)+diag(ones(bins-2,1),-2);
dcdc = [dcidci dcidci dcidci; dcidci dcidci dcidci; dcidci dcidci dcidci];
dcdq = diag(ones(nspecies*bins,1));
dcdT = repmat(dcidci,[nspecies,1]);
dqdq = diag(ones(nspecies*bins,1));
dqdc = repmat(diagonal,nspecies);
dqdT = repmat(diagonal,[nspecies,1])
dTdc = repmat(dcidci,[1,nspecies]);
dTdq = repmat(diagonal,[1,nspecies]);
dTdT = dcidci;
S = [dcdc dcdq dcdT; dqdc dqdq dqdT; dTdc dTdq dTdT];

Answers (0)

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!