I am converting Matlab code into R. In one case, there is a statement involving matrix sigma
. How can I translate that Matlab line into R syntax?
diag(1./sigma)
I know it gets the diagonal, but don't know what the 1./
is. My vague guess would be 1/sigma
. Is this correct?
In matlab, .*
and ./
are used to do element by element operations instead of cross multiplication. So in this case, you should just use 1/sigma
and make sure your R matrix after conversion iis one divided by each element in the original matrix.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.