Problem: Integrating symbolic expression with dblquad

2 visualizzazioni (ultimi 30 giorni)
Hi there
I have a long list of symbolic functions which I would like to integrate with dblquad (this is an example of one such function):
sym x y
FUN(ii)=1/(x^(4/7)*exp(1/(8*x))*exp(y^2/(3*x^(2/5))));
IntFUN(ii)=dblquad(@(x,y) FUN(ii),0.1,400,0,200)
But the integration itself fails (error: Matrix dimensions must agree). If instead I do it with "." before all */^ it works fine:
IntFUN(ii)=dblquad(@(x,y) 1./(x.^(4./7).*exp(1./(8.*x)).*exp(y.^2./(3.*x.^(2./5)))),0.1,400,0,200)
ans =
103.9509
Problem is, symbolic math apparently doesn't store the use of "." so I can't just convert all expressions to char, find the operators, add a "." and convert back to sym.
How do I solve this problem?

Risposta accettata

Walter Roberson
Walter Roberson il 7 Gen 2012
Use matlabFunction to convert the symbolic expression to a function handle.
You should not be using a symbolic expression for dblquad() -- dblquad() must be passed a function handle, and a symbolic expression is not a function handle.

Più risposte (1)

Jakob Sievers
Jakob Sievers il 7 Gen 2012
Thank you very much. That's exactly the piece of the puzzle I was missing.
You wouldn't happen to know if there's any fast way to do dblquad calls to a series of these functions (as defined through matlabFunctions)? The thing is, I have a few thousands of these equations, all of same structure but with varying constants. Since the equation appears unsolvable in an analytical form I have until now just set it up as a loop which runs dblquad for each equation, but more-often than not there are more clever, and timesaving, methods out there. I'm just not aware of any clever ways around this one.
  2 Commenti
Walter Roberson
Walter Roberson il 7 Gen 2012
If the structure is the same but the constants are different, you could use symbolic variables for the constants, matlabFunction() up the result, and pass the constants in using (e.g.)
@(x,y) mf_FUN{i}(x, y, c1, c2, c3)
where c1, c2, c3 had been retrieved (or calculated if appropriate)
Jakob Sievers
Jakob Sievers il 8 Gen 2012
Thanks for your help. I will try this approach.

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by