Double integration in matlab

2 次查看(过去 30 天)
AVM
AVM 2020-3-5
评论: AVM 2020-3-5
I would like to double integrate the following code, but some error is happenig. Pl somebody help me.
clc;
clear;
syms r1 theta1 n1 m1
r2=1.0;
theta2=2.0;
alpha1=0.5;
alpha2=1.0;
lambda=2.0;
omega=1;
phi=pi/3;
mu=cosh(r2);
nu=exp(1i*theta2).*sinh(r2);
beta1=r1.*exp(1i*theta1);
f1=exp(-((alpha1).^2)-((alpha2).^2)-((abs(beta1)).^2)-(1/mu).*real(((alpha2).^2)*conj(nu)));
f2=@(n1,m1)(((alpha1*conj(beta1))^(n1))./factorial(n1))*(((conj(alpha1)*(beta1))^(m1))/factorial(m1));
f3=1./sqrt((((mu).^2)-(abs(nu)).^2));
f4= exp((((1/mu).*real(((alpha2).^2)*conj(nu)))+(((alpha2).^2)))./((((mu).^2)-(abs(nu)).^2)));
Q1=(1/pi)*f1.*f3.*f4.*symsum(symsum(f2,n1,0,20),m1,0,20);
a1=@(r1,theta1)(1/2).*((beta1).*exp(-1i*phi)+conj(beta1).*exp(1i*phi)).*Q1;
a2=@(r1,theta1)(1/4)*(((beta1).^2)*exp(-2*1i*phi)+((conj(beta1)).^2)*exp(2*1i*phi)+(2*(abs(beta1)).^2)-1).*Q1;
x1=integral2(a1,0,10,0,2*pi)
x2=integral2(a2,0,10,0,2*pi)
Error using integral2Calc>integral2t/tensor (line 231)
Input function must return 'double' or 'single' values. Found 'sym'.

回答(1 个)

Steven Lord
Steven Lord 2020-3-5
Dont use integral or integral2 to integrate a symbolic function. Use one of the symbolic integration functions listed on this documentation page or use the matlabFunction function to create a numeric function suitable for use with integral or integral2 as per the examples on this documentation page.
  1 个评论
AVM
AVM 2020-3-5
Thanks. Then can I use
int(int(fun,r1,0,10),theta1,0,2*pi) % for double integration?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by