
alain,
 
    Perhaps i'm still entering the code wrong.  I tried using your  
result=myquadrature(f,0,2000)
print(result)
 
Instead of my:
val = myquadrature(f,a,b)
result=myquadrature(val,0,2000) 
print(result) 
 
...and I am still getting an inf inf inf inf inf...
 
Did you change any of the previous syntax in addition to changing the result statement?
 
Thank you so much and I think my brain is fried!  Happy Holiday.
 
Craig
 
> Date: Mon, 11 Oct 2010 09:59:17 +0200
> From: alain.guillet@uclouvain.be
> To: craigpoconnell@hotmail.com
> CC: pdalgd@gmail.com; r-help@r-project.org
> Subject: Re: [R] MATLAB vrs. R
> 
> Hi,
> 
> The first argument of myquadrature in result shouldn't be val but f I 
> guess. At least it works for me
> 
> > result=myquadrature(f,0,2000)
> > print(result)
> [1] 30000
> 
> Regards,
> Alain
> 
> 
> On 11-Oct-10 09:37, Craig O'Connell wrote:
> > Thank you Peter. That is very much helpful. If you don't mind, I continued running the code to attempt to get my answer and I continue to get inf inf inf....... (printed around 100 times).
> >
> > Any assistance with this issue. Here is my code (including your corrections):
> >
> >
> > myquadrature<-function(f,a,b){
> > npts=length(f)
> > nint=npts-1
> > if(npts<=1)
> > error('need at least two points to integrate')
> > end;
> > if(b<=a)
> > error('something wrong with the interval, b should be greater than a')
> > else
> > dx=b/real(nint)
> > end;
> > npts=length(f)
> > int=0
> > int<- sum(f[-npts]+f[-1])/2*dx
> > }
> >
> > #Call my quadrature
> > x=seq(0,2000,10)
> > h = 10.*(cos(((2*pi)/2000)*(x-mean(x)))+1)
> > u = 1.*(cos(((2*pi)/2000)*(x-mean(x)))+1)
> > a = x[1]
> > b = x[length(x)]
> > plot(x,-h)
> > a = x[1];
> > b = x[length(x)];
> > #call your quadrature function. Hint, the answer should be 30000.
> > f=u*h;
> > val = myquadrature(f,a,b); ? ___________This is where issue arises.
> > result=myquadrature(val,0,2000) ?
> > print(result) ?
> >
> >
> > Thanks again,
> >
> > Phil
> >
> >
> > 
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> -- 
> Alain Guillet
> Statistician and Computer Scientist
> 
> SMCS - IMMAQ - Université catholique de Louvain
> Bureau c.316
> Voie du Roman Pays, 20
> B-1348 Louvain-la-Neuve
> Belgium
> 
> tel: +32 10 47 30 50
> 
 		 	   		  
	[[alternative HTML version deleted]]

