How to construct a block diagonal combined with another block diagonal with an off diagonal?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
I am trying to get a matrix in the form
B 0 0 -I 0 0
0 B 0 A -I 0
0 0 B 0 A -I
with vectors: B = [5; 10]
A = [2 3; 8 6]
-I = [-1 0; 0 -1]
I used the code below for the scalar case but I am having trouble using it with vectors clear
A=0.95; B=.5; N=5;
A0=[B*eye(N) -eye(N)] for k=1:N-1 A0(k+1,N+k)=A; end
Output:
.5 0 0 -1 0 0
0 .5 0 .95 -1 0
0 0 .5 0 .95 -1
Any help will be greatly appreciated
Thanks in advance.
Answers (1)
Andrei Bobrov
on 27 Mar 2014
Edited: Andrei Bobrov
on 29 Mar 2014
M = {[5; 10], [2 3; 8 6],-eye(2)}
ii = tril(toeplitz ([3,2,0]))
v = zeros(size(i2));
for jj = 2:3
t = ii == jj;
v(t) = repmat(M{jj},1,jj);
end
out = [kron(eye(3),M{1}),v];
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!