フィルターのクリア

How to do a lower triangular with ones along the diagonal ?

7 ビュー (過去 30 日間)
z m
z m 2017 年 11 月 26 日
コメント済み: z m 2017 年 11 月 26 日
Hello,
I want to do a lower triangular with ones along the diagonal. for example, I have 62 x 62 matrix of (binary of 1s and 0s) and wants to transfer this matrix to a lower triangular with ones along the diagonal
here, I use zeros for create A= 62 x 62 matrix and used tril(A) to get the lower triangular matrix
A=zeros(62,62);
tril(A);
I get a lower triangular matrix but how to get a lower triangular with ones along the diagonal from matrix A?
please, help me.
Thanks

採用された回答

Walter Roberson
Walter Roberson 2017 年 11 月 26 日
Extracting the lower triangle from A and setting the main diagonal to 1:
tril(A,-1) + diag(ones(1,size(A,1))
Extracting the lower triangle from A and setting the first diagonal of the lower triangle to 1:
tril(A,-2) + diag(ones(1,size(A,1)-1),-1)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by