"bob bobby" wrote in message <ipa14h$quv$1@fred.mathworks.com>...
> 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+x1), @(s) 1s, 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 1s prior to the integration but I am totally lost.
> I would really appreciate some help here, many thanks.
>
> Regards,
> Robert
        
The outer variable of integration is 's' and the inner one is 'x', so you should have them arranged accordingly in 'quad2d'. You have them reversed. Also the integration limit function, 1s, should be given as the fourth argument, not the second one. Read over the documentation of 'quad2d' very carefully.
Perhaps you should try a very simple double integral with finite limits and with a variable lower inner limit whose answer you already know from calculus so as to check out your procedure. When you can get that one right you can advance to the one above.
Roger Stafford
