I need the nxn
matrix, where the first pxp
of them contains those, and the rest are zeros. I can do this by going through the cells, so I am not asking to do this. I am looking for a “MATLAB path” for this, using built-in functions and avoiding loops, etc.
To be more clear;
let n=4 and p=2
,
then the expected result:
1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0
There may be some more elegant solutions, so I will answer the shortest and most readable answer.
PS The title of the question looks somewhat irrelevant: I put this title because my initial approach would be to create a pxp
matrix with units, and then expand it to nxn
zeros.
source share