How to construct a block diagonal combined with another block diagonal with an off diagonal?

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)

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.

Asked:

on 27 Mar 2014

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!