# Creating Dynamic High Dimensional Block Diagonal Matrix

6 views (last 30 days)
Gözde Üstün on 27 Jun 2020
Edited: Gözde Üstün on 27 Jun 2020
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

R2020a

### Community Treasure Hunt

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

Start Hunting!

Translated by