MATLAB: Index in position 1 is invalid. Array indices must be positive integers or logical values ERROR

errormatrixmatrix array

hello ,
I try to create a matrix in which every element must have the same column sum of another matrix.
Specifically , i have this matrix :
0.9748 1
0.9748 1
0.5416 0.2996
and i want to create that matrix
0.9748+0.9748+0.5416 1+1+0.2996
0.9748+0.9748+0.5416 1+1+0.2996
0.9748+0.9748+0.5416 1+1+0.2996
i use this command :
second_term_denominator_2(j,i)=second_term_denominator_1(sum(second_term_denominator_1,i),i)
and it gives this error :
Index in position 1 is invalid. Array indices must
be positive integers or logical values.
Error in UNIFAC (line 67)
second_term_denominator_2(j,i)=second_term_denominator_1(sum(second_term_denominator_1,i),i)
I have attached the full folder of the code. I would be very gratefull if anyone could help me

Best Answer

hello.
you can use iteration like this
a =[ 0.9748 1;
0.9748 1;
0.5416 0.2996]
[x , y] = size(a);
for(i = 1:x)
for(j = 1:y)
second_term_denominator_2(i,j) = sum(a(:,j));
end
end