Hi all,
I am very new to mata and ran into a problem that I cannot figure out.
I created a matrix m (10x7) in mata and I am trying to populate the individual cells in matrix m from a forvalues loop in stata. I created a mata function called insert() so that I can call it in the forvalues loop but the function does not work as I intend it to. I would really appreciate the help as I am not sure what I am doing wrong. Thank you for the help! Here is the code I used and the error I get:
insert(): 3301 subscript invalid
<istmt>: - function returned error
I am very new to mata and ran into a problem that I cannot figure out.
I created a matrix m (10x7) in mata and I am trying to populate the individual cells in matrix m from a forvalues loop in stata. I created a mata function called insert() so that I can call it in the forvalues loop but the function does not work as I intend it to. I would really appreciate the help as I am not sure what I am doing wrong. Thank you for the help! Here is the code I used and the error I get:
Code:
mata
mata clear
m = J(10,7,0)
void insert(a) {
m[a,1] = a
}
end
forvalues i=1/10 {
mata insert(`i')
}
insert(): 3301 subscript invalid
<istmt>: - function returned error

Comment