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 で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!