s-news
[Top] [All Lists]

square wave function

To: s-news@lists.biostat.wustl.edu
Subject: square wave function
From: FolkesM@pac.dfo-mpo.gc.ca
Date: Tue, 27 Nov 2001 14:20:44 -0500
Has anybody built an efficient estimation function for a square wave?

Mine has loops and I'm clearly stuck in VB mode.

# Begin function
sqr.wave<-function(rads,terms)
{
sqr.data_rep(0,length(rads))
for(x1 in 1:length(rads)){
for(k in 0:terms)
        {
sqr.data[x1]<-sqr.data[x1]+(sin((2*k+1)*pi*rads[x1]))/(2*k+1)
}
}
return(sqr.data)
}



Thanks
Michael
________________________________________________________
Michael Folkes                  folkesm@pac.dfo-mpo.gc.ca
Fisheries & Oceans Canada               Tel (250) 756-7264
South Coast                             Fax (250) 756-7162
3225 Stephenson Point Road
Nanaimo, B.C.
Canada V9T 1K3 


<Prev in Thread] Current Thread [Next in Thread>
  • square wave function, FolkesM <=