Hi All,
I am trying to generate a sequence of 1's in row of a matrix where all other values remain 0. More specifically in the example code below, for the first row, the first 4 columns should be coded 1, in the second row, columns 5 through 8 should be coded 1, in row 3, columns 9 through 12 should be coded 1, etc...
I am trying to elaborate on the basic matrix code BB[1,1..4] = 1, to no success...
All help is welcome!
Ariel
I am trying to generate a sequence of 1's in row of a matrix where all other values remain 0. More specifically in the example code below, for the first row, the first 4 columns should be coded 1, in the second row, columns 5 through 8 should be coded 1, in row 3, columns 9 through 12 should be coded 1, etc...
I am trying to elaborate on the basic matrix code BB[1,1..4] = 1, to no success...
All help is welcome!
Ariel
Code:
local margcnt = 4 mat BB = J(`margcnt',`margcnt'^2,0) forval i = 1/`margcnt' { mat FF = BB[`i', ((`i' - 1) * `margcnt' + 1)..(`i' * `margcnt')] = 1 }
Comment