MATLAB: I have 30×30 matrix and need to extrapolate lower triangle numbers

extrapolatelower triangle

I need to pull out everything below the diagonal (the lower triagnle numbers), but I don't want to use tril and change the diagonal and upper triangle to zeros. I just want to pull out the lower triangle numbers so that I can make a vector out of its values.
Anything is helpful!! Thank you!

Best Answer

You just want to extract the lower triangle, whatever is in it? The result going into a vector?
A = magic(5) - 10
A =
7 14 -9 -2 5
13 -5 -3 4 6
-6 -4 3 10 12
0 2 9 11 -7
1 8 15 -8 -1
V = A(logical(tril(ones(size(A)))))
V =
7
13
-6
0
1
-5
-4
2
8
3
9
15
11
-8
-1
That includes the diagonal. But if you want the strictly lower triangle, just set a second argument for tril.