a problem in nested function which include triplequad integration
Mostrar comentarios más antiguos
dear friends
i want to do set of operation in matlab but i have a problem: first of all, i want to take 3variable integration from f which is function of x,y,z,m,a but i want to integrate only over x,y,z after that for a special "a" forexample a=100 i want to solve the equation.i mean one side of equation is the answer of that 3variable integration and the other side is just a number(330.734) in matlab my program is:
function myint=getintegral(m) a=100; myint=330.734-triplequad(@myfunction,-pi,pi,-pi,pi,-pi,pi);
function myfun=myfunction(x,y,z)
myfun=triplequad((4 *((-2* a + m).^2 *(4 *a + m) +4 *a.^2 *(2*(2*a - m)* cos(z) + cos(y) *(4* a - 2* m + 4 *a* cos(z) - m *cos(z)) + cos(x) *(4* a - 2* m + 4 *a* cos(z) - m *cos(z) + cos(y) *(4 *a - m + 4 *a* cos(z))))))./(m.^4 + 64 *a.^3 *m *(1 + cos(x)) *(1 + cos(y)) *(1 + cos(z)) - 8 *a.^2 *m.^2 *(3 + 2 *cos(z) + cos(y) *(2 + cos(z)) + cos(x) *(2 + cos(y) + cos(z))) + 16 *a.^4 *(-3 + cos(x).^2 *(cos(y) - cos(z)).^2 - 4 *cos(z) + cos(y) *(-4 + cos(z) *(-6 + cos(y) *cos(z))) - 2 *cos(x) *(2 + 3 *cos(z) + cos(y) *(3 + cos(z)* (6 + cos(y) + cos(z)))))),-pi,pi,-pi,pi,-pi,pi);
end %myfunction
end %getintegral
I wrote nested functions in matlab, then the inner function gets access to the outer function's variables and Used triplequad in a nested function (type this as a ".m" file) Then from the command line I can just type something like:
> fsolve(@getintegral,m_initialguess)
for my problem m_initialguess=3 also i must tell that I used ./ instead of / and also .^ instead of ^ because if I didnt do that Matlab couldnt solve and said that x y z are matrix
so for a special "a" i must find special "m"
but when i write it in matlab, it give errors like these:
??? Error using ==> fcnchk at 103 FUN must be a function, a valid string expression, or an inline function object.
Error in ==> triplequad at 45 intfcn = fcnchk(intfcn);
so what should i do?
Respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!