Hello World,
I have a vector
x = [x_1 x_2 x_3]
and would like to create a Matrix which looks like this:
X = [x_1 0 0 x_2 x_1 0 x_3 x_2 x_1]
Is there a loop-less way or a Matlab function to do this? The best thing I could come up with is:
x = 1:3 ;N = length(x) ;X = zeros(N) ;for kk=1:N X(kk:N+1:end) = x(kk) ;endX = tril(X)
Best Answer