5
$\begingroup$

I need to compute the integral $\int_{\mathbb{R}^3}f(x)\, dx$, where $f$ is a matrix-valued function $f:\mathbb{R}^3\to\mathbb{R}^{3\times 3}$. How do I do that using MATLAB? The function $f$ is implemented in a seperate file. It takes as input three vectors, giving the $x$-, $y$-, and $z$-coordinates of the points in which is has to be evaluated. As output it gives a 5D array.

If I just write integral3(@f,-1,1,-1,1,-1,1) for instance, I get the error Integrand output size does not match the input size.

$\endgroup$
  • 2
    $\begingroup$ What prevents you to perform the integration component-wisely? $\endgroup$ – Shuhao Cao Aug 9 '13 at 18:08
  • $\begingroup$ Apparently, the function given to integral3 should take three 2D arrays, which in my opinion seems a little strange. And my function take three vectors. $\endgroup$ – torbonde Aug 10 '13 at 18:51
2
$\begingroup$

I would write this as a comment to the answer by @Mohammad Bazrafshan but since i dont have enough reputation i will write it as an answer.

What he suggested works, the official documentation for it can be found here:

http://www.mathworks.com/help/matlab/ref/integral.html#inputs

You can see that the integral function has the potential to integrate array-valued functions, like vectors and matrices.

What it does is component-wise integration of the elements of the array, so it is the same as going through all elements of the array with a loop and performing integration of many scalar-valued functions.

$\endgroup$
1
$\begingroup$

use command "integral" and then set the following input argument: 'ArrayValued',true

$\endgroup$
  • $\begingroup$ This answer is pretty short. But the downvoter may expand on why it is not useful. Does the suggestion work or not? $\endgroup$ – Jan Sep 19 '14 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.