I have a vector v=[a b c d] and I want to (efficiently) create a matrix of the form : M=[a 0 0 0 ; b a 0 0 ; c b a 0 ; d c b a ]. I am experimenting with "diag" function but it does not seem to be very efficient. Any thoughts?
MATLAB: Creating triangular matrix from a vector (with a twist)
indexingmatrix manipulation
Best Answer