Pad a vector to get matrix
1 次查看(过去 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 中查找有关 3-D Scene Control 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!