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!