How do I map the elements of one matrix to another?
조회 수: 3 (최근 30일)
이전 댓글 표시
I am trying to transform a matrix A to A' where the indices are transformed by:
- y' = x
- x' = 1024-y
I am currently using the code:
for x = 1:1024
for y = 1:1024
f{x,y} = b(1024-y,x);
end;
end
but am getting a "Subscript indices must either be real positive integers or logicals." error. Any suggestions on how to do this?
댓글 수: 0
채택된 답변
Stephen23
2017년 7월 20일
편집: Stephen23
2017년 7월 20일
If b has 1024 rows then you will need:
1+1024-y
otherwise the lowest calculated index value will be zero (MATLAB indexing starts at one).
Better alternative: doing this in a loop is likely not very efficient, you should simply use indexing directly, e.g.:
fliplr(b.')
or
b(end:-1:1,:).'
댓글 수: 2
추가 답변 (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!