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

# Re: st: Element-by-element computation in Mata

 From Tirthankar Chakravarty To statalist@hsphsun2.harvard.edu Subject Re: st: Element-by-element computation in Mata Date Tue, 11 May 2010 00:12:37 +0530

*****************************************
clear*
mata
mA = runiform(10, 10)
dA = 2; dB = 3;
mB = mA:*(dA^2) :- dB
mB
end
*****************************************

T
2010/5/11  <mjbaker@hunter.cuny.edu>:
> Dear Listers:
> I am trying to do an element-by-element computation in mata but am not sure if it is possible. Given a matrix Z with elements z[I,j], what I would like to do is transform the elements of Z using scalars a and b to create a new matrix W as follows:
> w[i,j]=a^2*z[i,j])-b
> How might this be done using the element-by-element colon operator in mata, if it can be done?
> Best,
> Matt Baker
> *
> *   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/
>

--
To every ω-consistent recursive class κ of formulae there correspond
recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
belongs to Flg(κ) (where v is the free variable of r).

*
*   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/