How to generate 4x4 lower triangular matrix?
Show older comments
I want to generate the lower triangular matrix A1 using a for loop instead of using for example 'B(2) - B(1)' for a22 and so on in the matrix.
MATLAB
B = [17.000; 26.000; 29.000; 33.000];
A1 = [1 0 0 0; 1 T(2)-T(1) 0 0; 1 T(3)-T(1) (T(3)-T(1))*(T(3)-T(2)) 0;
1 T(4)-T(1) (T(4)-T(1))*(T(4)-T(2)) (T(4)-T(1))*(T(4)-T(2))*(T(4)-T(3))]; %Lower Triangular Matrix
end
Answers (1)
Andrei Bobrov
on 30 Nov 2017
a = tril(T(:) - T(:)');
A1 = cumprod([ones(numel(T),1),a(:,1:end-1)],2);
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!