# MATLAB: How to generate lower triangle in a matrix where elements are the inverse of the upper traingle and diagonal is one

MATLABmatrix

I want to generate a matrix where lower triangle elements are the inverse of upper triangle elements and diagonal elements are one.
where user inputs the upper triangle elements and lower triangle elements are generated automatically. I have attached the required matrix as an example. Thanks!

``>> M = [0 7 9 8;        0 0 8 6;        0 0 0 4;        0 0 0 0]M =     0     7     9     8     0     0     8     6     0     0     0     4     0     0     0     0>> MT = (1./M)'MT =       Inf       Inf       Inf       Inf    0.1429       Inf       Inf       Inf    0.1111    0.1250       Inf       Inf    0.1250    0.1667    0.2500       Inf>> x = logical(tril(ones(size(M)),-1))x =     0     0     0     0     1     0     0     0     1     1     0     0     1     1     1     0>> M(x) = MT(x)M =         0    7.0000    9.0000    8.0000    0.1429         0    8.0000    6.0000    0.1111    0.1250         0    4.0000    0.1250    0.1667    0.2500         0>> M(1:size(M,1)+1:end) = 1M =    1.0000    7.0000    9.0000    8.0000    0.1429    1.0000    8.0000    6.0000    0.1111    0.1250    1.0000    4.0000    0.1250    0.1667    0.2500    1.0000``