I have this matrix
K=
0 0 1
0 2 1
0 1 1
L=
1
3
2
where L
is the sum of each row of K
I need to make a new matrix through dividing each row of K
by its sum, for example from 2nd row [0 2 1]
the output that I should get is [0 2/3 1/3]
or [0 0.67 0.33]
:
Output=
0 0 1
0 0.67 0,33
0 0.5 0.5
I'm trying to use this code, but got only zeros:
for i=1:3;
j=1:3;
if K(i,j)>0
K(i,j)=(K(i,j))/L(i)
else
K(i,j)=0
end
end
How can I divide each row of K
by its own sum?