How to do Double integral with two function handle.

8 views (last 30 days)
%%%%% theta and omega1 are two variables
temp1=@(theta,omega1)-omega1.^2.*exp(-abs(omega1).*(cos(theta) + 5)).*(((6632097892526661.*exp(-omega1))./2814749767106560 + (2351843784080109.*omega1.^(5./2).*((7055531352240327.*exp(-omega1).*(3./omega1 + 3./omega1.^2 + 1))./(1125899906842624.*omega1.^(1./2)) + (3991211251234741.*2.^(1./2).*omega1.^(1./2).*exp(-omega1).*(1./omega1 + 1))./4503599627370496))./9007199254740992 - (3527765676120163.*omega1.^(3./2).*((8466637622688393.*exp(-omega1).*(1./omega1 + 1))./(2251799813685248.*omega1.^(1./2)) + (3991211251234741.*2.^(1./2).*omega1.^(1./2).*exp(-omega1))./4503599627370496))./4503599627370496 + 3.*pi.*exp(-omega1).*((5.*omega1)./2 + 5./2) + (696927317274246941282520301244943.*omega1.^2.*exp(-omega1).*(3./omega1 + 3./omega1.^2 + 1))./50706024009129176059868128215040 - (31361729277341114213626645380177.*omega1.*exp(-omega1).*(1./omega1 + 1))./1267650600228229401496703205376 - (238946508779741850518491294873107.*omega1.^3.*exp(-omega1).*(6./omega1 + 15./omega1.^2 + 15./omega1.^3 + 1))./202824096036516704239472512860160 - (15.*pi.*omega1.*exp(-omega1))./2)./omega1.^2 - (cos(theta) + 5).*(((45860953789562119.*omega1.^(3./2).*((7055531352240327.*exp(-omega1).*(3./omega1 + 3./omega1.^2 + 1))./(1125899906842624.*omega1.^(1./2)) - (3991211251234741.*2.^(1./2).*omega1.^(1./2).*exp(-omega1).*(6./omega1 + 15./omega1.^2 + 15./omega1.^3 + 1))./4503599627370496))./11258999068426240 - (45860953789562119.*omega1.^(1./2).*((8466637622688393.*exp(-omega1).*(1./omega1 + 1))./(2251799813685248.*omega1.^(1./2)) - (3991211251234741.*2.^(1./2).*omega1.^(1./2).*exp(-omega1).*(3./omega1 + 3./omega1.^2 + 1))./4503599627370496))./5629499534213120 + (345144957126293784082265203705599.*omega1.^3.*exp(-omega1).*(3./omega1 + 3./omega1.^2 + 1))./405648192073033408478945025720320 - (129429358922360136602258035107329.*omega1.^2.*exp(-omega1).*(1./omega1 + 1))./50706024009129176059868128215040)./omega1 - (abs(omega1).*((6632097892526661.*exp(-omega1))./2814749767106560 + (2351843784080109.*omega1.^(5./2).*((7055531352240327.*exp(-omega1).*(3./omega1 + 3./omega1.^2 + 1))./(1125899906842624.*omega1.^(1./2)) + (3991211251234741.*2.^(1./2).*omega1.^(1./2).*exp(-omega1).*(1./omega1 + 1))./4503599627370496))./9007199254740992 - (3527765676120163.*omega1.^(3./2).*((8466637622688393.*exp(-omega1).*(1./omega1 + 1))./(2251799813685248.*omega1.^(1./2)) + (3991211251234741.*2.^(1./2).*omega1.^(1./2).*exp(-omega1))./4503599627370496))./4503599627370496 + 3.*pi.*exp(-omega1).*((5.*omega1)./2 + 5./2) + (696927317274246941282520301244943.*omega1.^2.*exp(-omega1).*(3./omega1 + 3./omega1.^2 + 1))./50706024009129176059868128215040 - (31361729277341114213626645380177.*omega1.*exp(-omega1).*(1./omega1 + 1))./1267650600228229401496703205376 - (238946508779741850518491294873107.*omega1.^3.*exp(-omega1).*(6./omega1 + 15./omega1.^2 + 15./omega1.^3 + 1))./202824096036516704239472512860160 - (15.*pi.*omega1.*exp(-omega1))./2))./omega1.^2));
fun = integral2(temp1.*cos(omega1.*a1.*sin(theta)),0,2.*pi,0,inf)
%%% getting error "Error using integral2 (line 82) , First input argument must be a function handle."
%% I am a beginner and need help in double integration.Thank you in advance!!

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 13 Aug 2021
Should look something like this:
fun = integral2(@(theta,omega1) temp1(theta,omega1).*cos(omega1.*a1.*sin(theta)),0,2.*pi,0,inf);
(I'm think I got the ordering of your variables right.) Your temp1 (templ?) variable can be treated as a function pretty much like any other function (built-in, matlab-native of from your toolboxes) except from a computational efficiency viewpoint perhaps.
HTH
  2 Comments
Bjorn Gustavsson
Bjorn Gustavsson on 13 Aug 2021
My pleasure.
Getting used to function-handles was something that took me a bit longer than the other variable-types - but it is worth the effort.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!