Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Mata: editing values in a matrix when a condition is met


From   Pablo Mitnik <[email protected]>
To   [email protected]
Subject   st: Mata: editing values in a matrix when a condition is met
Date   Tue, 07 Feb 2012 19:10:56 -0800

Dear all,

I need to edit the values of a large matrix in Mata. More precisely, I need to replace all values smaller than a number X by X, and all numbers greater than Y by Y. The functions editvalue and _editvalue allow you to replace a scalar by other in a matrix, but not to specify a condition like x < X to trigger the replacement. Is there a way of doing this economically, that is, without looping over all elements of the matrix?

Any help would be greatly appreciated.

All best,

Pablo Mitnik
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index