From: C Berry on
Hi,

I have a function that produces a vector output, something like

h = myfun(cos_theta, phi, params);

where h is a vector. I would like to integrate h over all angles, so for cos_theta = -1 ... 1 and phi = 0 ... 2pi. I was looking at quad2d to perform the integration, but it doesn't like integrating a vector function. Is it possible to get around this? I can't loop over each element of h (so I can't average h(1), then h(2), then h(3)... ) as I cannot calculate each element independently: I would have to calculate the whole of h each time, and this would be horrendously inefficient.

Thanks,

Christopher
From: John D'Errico on
"C Berry" <cplb2(a)cam.ac.uk> wrote in message <hvt0to$1at$1(a)fred.mathworks.com>...
> Hi,
>
> I have a function that produces a vector output, something like
>
> h = myfun(cos_theta, phi, params);
>
> where h is a vector. I would like to integrate h over all angles, so for cos_theta = -1 ... 1 and phi = 0 ... 2pi. I was looking at quad2d to perform the integration, but it doesn't like integrating a vector function. Is it possible to get around this? I can't loop over each element of h (so I can't average h(1), then h(2), then h(3)... ) as I cannot calculate each element independently: I would have to calculate the whole of h each time, and this would be horrendously inefficient.
>

help quadv

HTH,
John