Upper triangular matrix

User ForumUpper triangular matrix
pvg asked 3 years ago

Hi,

what is the most efficient way of creating an upper triangular matrix?

Thanks

Pablo

1 Answers
Best Answer
caj1024 answered 3 years ago

If you are starting with an Nx1 vector you could use the xpnd and upmat functions like this:

d = { 1, 2, 3, 4, 5, 6 };
d_upper = upmat(xpnd(d));

d_upper =

   1    2    4 
   0    3    5 
   0    0    6