Hi guys, I need your help.
I want to create a matrix(4,4) in which the main diagonal have values between 0.3 and 1 and the other cells assume values such as to have a horizontal sum equal to 1.
By now I'm using the following code but the only result is to have a main diagonal composed by the same numbers:
x = eye(4)
x(1,1) = 1+(0.3-1)*rand(1,1)
x(2,2) = x(1,1)
x(3,3) = x(1,1)
x(4,4) = x(1,1)
Any suggestion?
PS : I've tried even with diag
2 Comments
Stephen Cobeldick (view profile)
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/480247-main-diagonal-operations-problem#comment_745526
Giuseppe Pintori (view profile)
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/480247-main-diagonal-operations-problem#comment_745571
Sign in to comment.