フィルターのクリア

Pad a vector to get matrix

1 回表示 (過去 30 日間)
Mori
Mori 2016 年 7 月 26 日
編集済み: Andrei Bobrov 2016 年 7 月 26 日
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 日
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 日
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);

カテゴリ

Help Center および File ExchangeTime Series についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by