フィルターのクリア

Creating Dynamic High Dimensional Block Diagonal Matrix

3 ビュー (過去 30 日間)
Gözde Üstün
Gözde Üstün 2020 年 6 月 27 日
編集済み: Gözde Üstün 2020 年 6 月 27 日
Hello,
I can create a matrix for dimenson = 2. However for even d and d>2, It should be a lock diagonal matrix of the previous result. I cannot run my code. I tried too many combination but I dont know how I can solve my problem
Here is my code:
A=zeros(d,d,2,d);
B=A;
projectors_of_sigma_x = [1/sqrt(2)*[1;1],1/sqrt(2)*[1;-1]];
for k = 1:d
A(:,:,1,k)=repmat(projectors_of_sigma_x(:,k),1,d); % In this line I am giving the value (1/sqrt(2)*[1;1]) to A(:,:,1,1) and value 1/sqrt(2)*[1;-1] to A(:,:,1,2)
if k > 2
A(:,:,1,k) = repmat({A(:,:,1,k)}, 1, d/2); %This line and the following line I am trying to create a matrix which is a blog diagonal of the previous result for even d and of course d>2
A(:,:,1,k) = blkdiag(A{:,:,1,k});
end
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by