I have a matrix A like above, how I can get matrix B as result of rotated matrix A in space?

 채택된 답변

Mori
Mori 2016년 7월 26일

0 개 추천

A=[10 12 3 34 5]
B=A(1,1)
numel(A)
for i=2:1:numel(A)
B=padarray(B,[1,1],A(1,i))
end

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2016년 7월 26일
편집: Andrei Bobrov 2016년 7월 26일

1 개 추천

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);

카테고리

도움말 센터File Exchange에서 Computational Geometry에 대해 자세히 알아보기

질문:

2016년 7월 26일

편집:

2016년 7월 26일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by