Path: news.mathworks.com!not-for-mail
From: "Steven_Lord" <slord@mathworks.com>
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$1@fred.mathworks.com>
References: <2d350472-226f-4122-8c33-4ed7b7ee5ddc@t19g2000prd.googlegroups.com>
NNTP-Posting-Host: ah-slord.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain;
	format=flowed;
	charset="iso-8859-1";
	reply-type=original
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1303246763 20331 172.31.44.225 (19 Apr 2011 20:59:23 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 19 Apr 2011 20:59:23 +0000 (UTC)
In-Reply-To: <2d350472-226f-4122-8c33-4ed7b7ee5ddc@t19g2000prd.googlegroups.com>
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: news.mathworks.com comp.soft-sys.matlab:722809



"tzygmund" <tzygmund@googlemail.com> wrote in message 
news:2d350472-226f-4122-8c33-4ed7b7ee5ddc@t19g2000prd.googlegroups.com...
>
> 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);

http://www.mathworks.com/help/techdoc/ref/quad.html

"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
slord@mathworks.com
To contact Technical Support use the Contact Us link on 
http://www.mathworks.com