I am kind of curious whether this can work. I use a program to test it, but it does not work well. I think there is something wrong with my code but I cannot tell. Matrix C turns out to be a 1*1 matrix and with missing values. I am not sure where went wrong. Thank you so much!
capture program drop tt11
program tt11
version 13
mat AA = (1,2,4,5)
mata: test10_1("AA")
mat A2 = r(A2)
mata: test10_2("AA")
mat B2 = r(B2)
mat C = B2 - A2
end
capture mata mata drop test10_1()
capture mata mata drop test10_2()
mata:
void test10_1(string scalar A)
{
real matrix A1, A2
A1 = st_matrix("A")
A2 = A1 * 2
st_matrix("r(A2)",A2)
}
void test10_2(string scalar B)
{
real matrix B1, B2
B1 = st_matrix("A")
B2 = B1 * 3
st_matrix("r(B2)",B2)
}
end
capture program drop tt11
program tt11
version 13
mat AA = (1,2,4,5)
mata: test10_1("AA")
mat A2 = r(A2)
mata: test10_2("AA")
mat B2 = r(B2)
mat C = B2 - A2
end
capture mata mata drop test10_1()
capture mata mata drop test10_2()
mata:
void test10_1(string scalar A)
{
real matrix A1, A2
A1 = st_matrix("A")
A2 = A1 * 2
st_matrix("r(A2)",A2)
}
void test10_2(string scalar B)
{
real matrix B1, B2
B1 = st_matrix("A")
B2 = B1 * 3
st_matrix("r(B2)",B2)
}
end
Comment