I have a matrix D = zeros (30, 432);
i want to assign d = [ 1 1 0 0; 0 0 1 1; 0 0 0 0];
to the diagonals of matrix D. i have the code below but it doesn't allow me to assign d for every diagonal values in D.
[N,~,P,Q]=size(D);
diagIndex=repmat(logical(eye(N)),[1 1 P Q]);
D(diagIndex)=d;
The output for 30x432 matrix would be like :
d 0 0 0
0 d 0 0
0 0 d 0
0 0 0 d