MATLAB: Matrix Manipulations – How to achieve these specific forms

loopsmanipulationMATLABmatricesmatrixvector

Dear Community,
I am struggling to achieve two distinct forms of matrices.
1) I want to build a matrix with the following form and dimensions of [8760 x 2*8760]
(1 1 0 0 0 0 ...
0 0 1 1 0 0 ...
0 0 0 0 1 1 ...
...)
2) I want to build a matrix with the following form and dimensions of [2*8760 x 2*8760]
(0 0 0 0 0 0 ...
5 8 0 0 0 0 ...
0 0 0 0 0 0 ...
5 8 5 8 0 0 ...
...)
I just can't make that work, also I am fairly new to Matlab. I really hope somebody can see a solution here.
Thanks a lot, Mathias

Best Answer

Bruno's and KSSV's answers do not create the matrices you asked for, or am I mistaken? Anyways, here are my suggestions:
N = 4 ; % small example, rather than N=8760
M1 = kron(eye(N), [1 1])
% 1 1 0 0 0 0 ...
% 0 0 1 1 0 0 ...
% 0 0 0 0 1 1 ...
% ...

M2 = kron(tril(ones(N)), [0 0 ; 5 8])
% 0 0 0 0 0 ...

% 5 8 0 0 0 ...
% 0 0 0 0 0 ...
% 5 8 5 8 0 ...
% ...