2017-06-22 52 views
2

我一直在试图找出这个积分一段时间,但总结出来了。我试图做一个象征性的整合,但是我把它反射回来,所以我假设没有解决方法。我已经解决了定积分来解决这个问题,但仍不断收到错误:如何整合一个复杂的功能?

clear 
clc 

x = 1; 
y = 1; 
z = 1; 
R = 2; 

b [email protected](theta) y.*cos(theta)/((x-R.*cos(theta)).^2+y.^2+(z - 
      R.*sin(theta)).^2).^(3/2) 

integral(b,1,2) 

我现在的错误是:

Error using integralCalc/finalInputChecks (line 515) 
Output of the function must be the same size as the input. If FUN is an array-valued 
integrand, set the 'ArrayValued' option to true. 

Error in integralCalc/iterateScalarValued (line 315) 
       finalInputChecks(x,fx); 

Error in integralCalc/vadapt (line 132) 
      [q,errbnd] = iterateScalarValued(u,tinterval,pathlen); 

Error in integralCalc (line 75) 
     [q,errbnd] = vadapt(@AtoBInvTransform,interval); 

Error in integral (line 88) 
Q = integralCalc(fun,a,b,opstruct); 

任何帮助将是非常赞赏!

回答

1

您需要在第一个任期内改变除号从/./,以确保你正在做element-wise division,而不是matrix right division

b = @(theta) y.*cos(theta)./((x-R.*cos(theta)).^2+y.^2+(z - ... 
      R.*sin(theta)).^2).^(3/2); 
integral(b,1,2) 

ans = 

    0.055781612354862