Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[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 <pmitnik@ssc.wisc.edu>
To   statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index