Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Matrix Calculations


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Matrix Calculations
Date   Thu, 1 Aug 2002 10:27:54 +0100

christopher@fergusson030481.freeserve.co.uk
>
> I have a 2*1 matrix and wish to produce another matrix
> containing simply the square root values of this matrix.

mat b = J(2,1,1)
forval i = 1/2 {
	mat b[`i',1] = sqrt(a[`i',1])
}

What you put in b[,] initially is arbitrary as each element
is overwritten.

The general principle is exactly that explained in the FAQ referred to
yesterday:

How do I perform element-by-element operations on matrices?
http://www.stata.com/support/faqs/data/matrix.html

Nick
n.j.cox@durham.ac.uk

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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   |   What's new   |   Site index