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]
Re: st: Exponential function on matrix
From 
 
Nick Cox <[email protected]> 
To 
 
[email protected] 
Subject 
 
Re: st: Exponential function on matrix 
Date 
 
Tue, 19 Jun 2012 21:33:03 +0100 
You can do this in Mata.
. mata :
: exp((0,1\2,3))
                 1             2
    +-----------------------------+
  1 |            1   2.718281828  |
  2 |  7.389056099   20.08553692  |
    +-----------------------------+
You can also pass a Stata matrix into Mata to do this and pull back the result.
. matrix foo = (0,1\2,3)
. mata : st_matrix("foobar", exp(st_matrix("foo")))
. mat li foobar
foobar[2,2]
           c1         c2
r1          1  2.7182818
r2  7.3890561  20.085537
On Tue, Jun 19, 2012 at 9:00 PM, Haiyong Xu <[email protected]> wrote:
> I want to apply exponential function on each cell of a matrix. Is there an
> easy way such as exp(matA) instead of loop? Thank you very much!
*
*   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/