Hi, guys. How would one extract the lower triangle of a matrix without using the tril function and witout a for loop?
이전 댓글 표시
I tried
B = zeros(size(A)); n=size(A,2);
for(i=1:n) B(end+1:end+n-i+1)=A(i:n,i); end
but I seem to be getting some sort of error.
Thanks
댓글 수: 1
Jos (10584)
2015년 4월 8일
What do you mean with "some sort of error"?
채택된 답변
추가 답변 (1개)
Jos (10584)
2015년 4월 8일
A = rand(5) ; %
[c,r] = meshgrid(1:size(A,1),1:size(A,2))
trilA = A ;
trilA(c>r) = 0
diagA = A ;
diagA(c ~= r) = 0
카테고리
도움말 센터 및 File Exchange에서 Linear Algebra에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!