Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Double integration
Date: Wed, 27 Apr 2011 21:17:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 21
Message-ID: <ipa14h$quv$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1303939025 27615 172.30.248.45 (27 Apr 2011 21:17:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 27 Apr 2011 21:17:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2669560
Xref: news.mathworks.com comp.soft-sys.matlab:724155

hi all!
I've been struggling to figure out how to calculate this double integral using matlab for the last few days and I'm totally stuck. I've read a wide variety of posts about double integrations and quad2d and dblquad but I'm no closer to figuring this out. I'm trying to integrate the following equation (safe link on imageshack):

http://img844.imageshack.us/i/codecogseqn3.gif/

where s and x are random variables and f(x) and g(s) are the respective pdfs.

I have tried to use the following 
quad2d(@(x,s) normpdf(s).*normpdf(x).*(s+x-1), @(s) 1-s, 500, -500, 500);

but I get this error message:
??? Error using ==> quad2d at 97
A must be a finite, scalar, floating point constant.

which makes sense sure, and I tried switching round the s and the x the limits but I am getting weird results and I am pretty certain it's totally wrong to do this.

I think I need to use a loop to compute the 1-s prior to the integration but I am totally lost. 
I would really appreciate some help here, many thanks.

Regards,
Robert