| 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> |
|---|---|---|
| ||
| Previous by Date: | Re: object table format, Prof Brian Ripley |
|---|---|
| Next by Date: | FORTRAN compiler for HP UNIX, Barker, Chris {PBSE~Palo Alto} |
| Previous by Thread: | object table format, Winifred Lambert |
| Next by Thread: | FORTRAN compiler for HP UNIX, Barker, Chris {PBSE~Palo Alto} |
| Indexes: | [Date] [Thread] [Top] [All Lists] |