How easy is it to combine symbolic and numeric computation in Matlab?

CS Beta people:

I have been doing some multiple integrals with a combination of symbolic and numerical integration (because symbolic answers have not always been possible). I have been using Mathematica to do the symbolic integration, cut-and-pasting the results into Matlab, and then using quad or dblquad in Matlab. I could probably do the whole thing in Mathematica, but I would like to develop my Matlab skills. My question is, is there a convenient way to use Matlab's symbolic capabilities to do this more efficiently, without cut-and-pasting?

The only symbolic engine I have access to in Matlab is mupad (I don't have the Maple Toolbox, for example). I would consult the Mathworks documentation, but I have found it deficient on several other questions, and I would like to hear from someone who has actually done it.

EDIT (March 5): Someone asked me to be more specific. Here is part of what I'm doing. I want to evaluate the triple integral

$$\int_1^{RmaxOverRmin} \int_1^{r_2}\int_0^{r_2-r_1}\frac{r_1^3 t^2}{r_2^3}\exp(-\frac{t^2}{4 dOverRmin^2})\,dt\,dr_1\,dr_2.$$

Mathematica can't do it symbolically, so it is probably impossible. Mathematica can do the inner double integral symbolically. So I did it, cut-and-pasted the results into a Matlab function file, and used Matlab's "quad" to integrate the result as $r_2$ went from $1$ to $RmaxOverRmin$.

Stefan (STack Exchange FAN)

• Yes, I've done this sort of thing exactly. Your problem is still a bit too general, if you'd like a specific answer (instead of a comment), could you post a more specific problem, giving the details of the numerical integration you are trying to do? – Aron Ahmadia Mar 5 '13 at 0:58
• In my experience if you need to do anything symbolic, you're best off sticking with Mathematica. Matlab can probably do it, but it is atrocious. – Victor Liu Mar 5 '13 at 6:29
• If you are not tied to Matlab, you could check out the combination of NumPy/SciPy and SymPy. – Christian Clason Mar 5 '13 at 9:49
• @Aron : I added to my question. – Stefan Smith Mar 5 '13 at 16:25

Otherwise you could just write the expressions into text files. Then you can run f=sym(somestring); to have MATLAB parse it into a symbolic object. Then just substitute using subs().