Given an nxn matrix A, how do I produce a lower triangular matrix with ones on the diagonal?

조회 수: 1 (최근 30일)
Given an nxn matrix A, how do I produce a lower triangular matrix with ones on the diagonal?
I tried
A = rand(n,n);
L = tril(A,1) + diag(ones(1, size(A,1))) ;
but it isn't working.

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2019년 9월 23일
tril(A,-1)+eye(n)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by