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

st: RE: Matrix Calculations


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Matrix Calculations
Date   Thu, 1 Aug 2002 10:27:54 +0100

[email protected]
>
> 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
[email protected]

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index