Pad a vector to get matrix
조회 수: 7 (최근 30일)
이전 댓글 표시

I have a matrix A like above, how I can get matrix B as result of rotated matrix A in space?
댓글 수: 0
채택된 답변
추가 답변 (1개)
Andrei Bobrov
2016년 7월 26일
편집: Andrei Bobrov
2016년 7월 26일
A = 5:-1:0;
n = numel(A);
B = zeros(2*n-1);
B(n,n) = 1;
B = A(bwdist(B,'chessboard') + 1)
or without Image Processing Toolbox
A = [10 12 3 34 5];
n = numel(A);
[ii,jj] = ndgrid(1:2*n-1);
B = A(max(abs(ii-n),abs(jj-n))+1);
or
A = [10 12 3 34 5];
n = numel(A);
p = 1:2*n-1;
z = toeplitz(p,p);
B = A((z + z(end:-1:1,:))/2);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Computational Geometry에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!