Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: mata function : coding optional argument

From   "U.A.QU.AP" <[email protected]>
To   [email protected]
Subject   st: mata function : coding optional argument
Date   Mon, 17 Apr 2006 19:22:22 +0100 (CET)

sorry my first message was without subject
I'm writing a mata function say: 
transmorphic matrix chak(real colvector dim1, real colvector
dim2, | real colvector pop , real scalar b)
in which "pop" and the scalar "b" are optional arguments as
you can see above
My question is how to code the optional arguments. I want that
if user dont specifies  the vector "pop"  mata must replace it
by a vector of ones  and similary for b.
Following the help my solution was
if (nb_arg<3) pop=J(rows(dim1),1,1)
if (nb_arg<4) b=1
but this solution don't allow  the user to specifies the
scalar b and omit the 3rd argument pop
Any help
AbdelRahmen El Lahga
*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index