Too slow using int, want to replace with integral2 or integral 3?
3 views (last 30 days)
Show older comments
I am trying to solve a double integral in Matlab using two int functions, the equation is in spherical coordinate. It takes too long and sometimes gives an out of memory message, is there a way to solve this integration in the spherical coordination using integral2 or integral3 built-in functions?
if true
% code
end
syms theta phi real
sin_alpha = sin(theta)*cos(phi);
sin_beta = sin(theta)*sin(phi);
Term1 = repmat((0:4-1)*sin_beta,4,1);
Term2 = repmat((0:4-1)*sin_alpha,4,1)';
AF_Field = sum(sum(exp(1i*(Term1+Term2)),2));
U = abs((AF_Field)).^2; % Radiation Intensity
L1 = 0; L2 = pi; % limits for theta
L3 = 0; L4 = 2*pi; % limits for phi
I1 = int(U*sin(theta),theta,L1,L2); % theta-integral
I = int(I1,phi,L3,L4); % phi-integral
Prad = double(I);
0 Comments
Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!