フィルターのクリア

Fast way to replicate array

3 ビュー (過去 30 日間)
Thang Bui
Thang Bui 2015 年 4 月 28 日
編集済み: Andrei Bobrov 2015 年 4 月 28 日
I have a matrix W of size ExF, and I have a matrix D of size NxFxNxE where D(n,:,n,:) = W'
Is there a fast way to replicate W to form D without having to loop through N
Thanks!

採用された回答

Mohammad Abouali
Mohammad Abouali 2015 年 4 月 28 日
編集済み: Mohammad Abouali 2015 年 4 月 28 日
w=[1 2; ...
3 4; ...
5 6];
N=5;
E=size(w,1);
F=size(w,2);
D=repmat(reshape(w',1,F,1,E),N,1,N,1);

その他の回答 (2 件)

Jan
Jan 2015 年 4 月 28 日
You want to obtain W from D?
W = squeeze(D(k, :, k, :)).'
  1 件のコメント
Thang Bui
Thang Bui 2015 年 4 月 28 日
編集済み: Thang Bui 2015 年 4 月 28 日
Nope, obtain D from W, the loop version looks roughly like this
D = zeros(N,F,N,E);
for n = 1:N
D(n,:,n,:) = W'; % perhaps need permute here
end

サインインしてコメントする。


Andrei Bobrov
Andrei Bobrov 2015 年 4 月 28 日
編集済み: Andrei Bobrov 2015 年 4 月 28 日
i1 = bsxfun(@plus,[0;N]+1,(0:N-1)*(2*N+1));
i2 = bsxfun(@plus,i1,reshape((0:F)*i1(end),1,1,[]));
D = zeros(N,F,N,E);
D(i2) = permute(repmat(W,[1,1,N]),[2,3,1]);

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by