How to generate 4x4 lower triangular matrix?
이전 댓글 표시
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
답변 (1개)
Andrei Bobrov
2017년 11월 30일
a = tril(T(:) - T(:)');
A1 = cumprod([ones(numel(T),1),a(:,1:end-1)],2);
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!