フィルターのクリア

Define a matrix in terms of kronecker product

2 ビュー (過去 30 日間)
Shilpi Mishra
Shilpi Mishra 2021 年 6 月 13 日
コメント済み: Matt J 2021 年 6 月 15 日
I want to represent the (n^2)x(n^3) binary matrix below in terms of kron(A,B), where A and B are defined in terms of n. In the example shown, n=3. The vacant entries are 0 and the 1s occur in shown pattern.

採用された回答

Matt J
Matt J 2021 年 6 月 13 日
n=3;
e=ones(1,n);
A=eye(n);
B=kron(e,A);
p=reshape(1:n^2,n,[]).';
C=kron(A,B);
C=C(p,:)
C = 9×27
1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1
  2 件のコメント
Shilpi Mishra
Shilpi Mishra 2021 年 6 月 14 日
Thank you, it worked. Can the last step C=C(p,:) be done using some matrix operation like matrix multiplication?
Matt J
Matt J 2021 年 6 月 15 日
Yes.
n=3;
e=ones(1,n);
A=eye(n);
B=kron(e,A);
p=reshape(1:n^2,n,[]).';
P=eye(n^2); P=P(p,:);
C=P*kron(A,B)
C = 9×27
1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1

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

その他の回答 (2 件)

dpb
dpb 2021 年 6 月 13 日
編集済み: dpb 2021 年 6 月 13 日
>> I=3;N=4;
>> kron(ones(1,N),eye(I))
ans =
1 0 0 1 0 0 1 0 0 1 0 0
0 1 0 0 1 0 0 1 0 0 1 0
0 0 1 0 0 1 0 0 1 0 0 1
>>
  1 件のコメント
Shilpi Mishra
Shilpi Mishra 2021 年 6 月 13 日
Thanks for your reply, but the pattern needed is different. Each row has got three 1s appearing in a pattern overall as shown. The size of the matrix in the example is 9x27.

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


Matt J
Matt J 2021 年 6 月 13 日
編集済み: Matt J 2021 年 6 月 13 日
n=3;
I=eye(n);
e=ones(1,n);
z=zeros(1,n);
C=cell(n,1);
for i=1:n
q=z;
q(i)=1;
C{i}=kron(kron(I,e),q);
end
C=cell2mat(C)
C = 9×27
1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by