From: "Steven_Lord" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: quad error
Date: Tue, 19 Apr 2011 16:59:41 -0400
Organization: MathWorks
Lines: 39
Message-ID: <iokt3b$jrb$>
References: <>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
X-Trace: 1303246763 20331 (19 Apr 2011 20:59:23 GMT)
NNTP-Posting-Date: Tue, 19 Apr 2011 20:59:23 +0000 (UTC)
In-Reply-To: <>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: comp.soft-sys.matlab:722809

"tzygmund" <> wrote in message
> Hello,
> I have a simple function to numerically integrate and it depends on
> the scalar 't':
> %%%%%%%%%%%%%%%%%
> function omegafun = omegafun(mM1, t)
> omegafun =  sqrt(det(eye(size(mM1, 1)) -2*t.*mM1))
> end
> %%%%%%%%%%%%%%%%%
> Here mM1 is a parameter matrix. I am able to compute this function and
> plot it, but when I try quad,
> quad(@(t) omegafun(mM1, t), 0, 10);

"The function y = fun(x) should accept a vector argument x and return a 
vector result y, the integrand evaluated at each element of x."

From your description it sounds like your function cannot handle a vector 
input t. Modify it so that it can by doing something like looping over the 
elements of t. Don't forget to preallocate omegafun to be the same size and 
shape as t.

omegafun = zeros(size(t));

Steve Lord
To contact Technical Support use the Contact Us link on