Hello,
I have been struggling to figure out a way to index elements of a mata matrix conditionally. My ultimate goal is as follows:
Consider two n by k matrices A and B, where B contains only 0s and 1s. I would like to place missing values into A at those indices where B is equal to 0.
If the goal was to place something other than missing values (for example say we wanted to place the number 23), then something like:
C = A:*B + J(n,k,23):*(J(n,k,1):-B)
would do the trick. Unfortunately replacing J(n,k,23) by J(n,k,.) does not work.
Any ideas on how to accomplish this?
Regards,
Max
I have been struggling to figure out a way to index elements of a mata matrix conditionally. My ultimate goal is as follows:
Consider two n by k matrices A and B, where B contains only 0s and 1s. I would like to place missing values into A at those indices where B is equal to 0.
If the goal was to place something other than missing values (for example say we wanted to place the number 23), then something like:
C = A:*B + J(n,k,23):*(J(n,k,1):-B)
would do the trick. Unfortunately replacing J(n,k,23) by J(n,k,.) does not work.
Any ideas on how to accomplish this?
Regards,
Max
Comment