i want to get top right n x n matrix out of Nx N, I programmed it in following way but i got answer two times. so what is my mistake?
조회 수: 1 (최근 30일)
이전 댓글 표시
a = top_right(N,n)
[j , k] = size(N);
a = N([1:1:j-(j-n) , 1:1:k-(k-n)],1:n);
end
댓글 수: 0
답변 (1개)
James Tursa
2018년 11월 19일
편집: James Tursa
2018년 11월 19일
For "top right corner," the column indexing should not start at 1. E.g.,
a = N(1:n,end-n+1:end); % <-- Back off from end instead of starting from 1
But you might want to add code to cover the cases where the dimensions of N are smaller than n.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!