필터 지우기
필터 지우기

Integrand output size does not match the input size. Kindly help me clear the error.

조회 수: 5 (최근 30일)
CODE:
%all variables are declared
for ai=a-2*(N-1)*wd-2*(N-1)*s:2*(wd+s):a-2*(N-N)*wd-2*(N-N)*s
for aj=a-2*(N-1)*wd-2*(N-1)*s:2*(wd+s):a-2*(N-N)*wd-2*(N-N)*s
Bz= @(x,y) (((u./(4.*pi)).*((((((-1).^1).*d1(ai))./(r1(ai).*(r1(ai)+((-1).^(1+1)).*C1(ai))))-(C1(ai)./(r1(ai).*(r1(ai)+d1(ai)))))+(((((-1).^2).*d2(ai))./(r2(ai).*(r2(ai)+(((-1).^(2+1))).*C2(ai))))-(C2(ai)./(r2(ai).*(r2(ai)+d2(ai)))))+(((((-1).^3).*d3(ai))./(r3(ai).*(r3(ai)+(((-1).^(3+1))).*C3(ai))))-(C3(ai)./(r3(ai).*(r3(ai)+d3(ai)))))+(((((-1).^4).*d4(ai))./(r4(ai).*(r4(ai)+((-1).^(4+1)).*C4(ai))))-(C4(ai)./(r4(ai).*(r4(ai)+d4(ai))))))))
M=integral2(Bz,-aj,aj,-aj,aj)
Mtl=Mtl+M
Mtotal=(Mtl./2).*J.*G
hold on
end
end
ERROR:
Error using integral2Calc>integral2t/tensor (line 241)
Integrand output size does not match the input size.
Error in integral2Calc>integral2t (line 55)
[Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);
Error in integral2Calc (line 9)
[q,errbnd] = integral2t(fun,xmin,xmax,ymin,ymax,optionstruct);
Error in integral2 (line 106)
Q = integral2Calc(fun,xmin,xmax,yminfun,ymaxfun,opstruct);
Error in FPSSCFINAL10Sep192 (line 108)
M=integral2(Bz,-aj,aj,-aj,aj)
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 9월 11일
You have
Bz= @(x,y) (((u./(4.*pi)).*((((((-1).^1).*d1(ai))./(r1(ai).*(r1(ai)+((-1).^(1+1)).*C1(ai))))-(C1(ai)./(r1(ai).*(r1(ai)+d1(ai)))))+(((((-1).^2).*d2(ai))./(r2(ai).*(r2(ai)+(((-1).^(2+1))).*C2(ai))))-(C2(ai)./(r2(ai).*(r2(ai)+d2(ai)))))+(((((-1).^3).*d3(ai))./(r3(ai).*(r3(ai)+(((-1).^(3+1))).*C3(ai))))-(C3(ai)./(r3(ai).*(r3(ai)+d3(ai)))))+(((((-1).^4).*d4(ai))./(r4(ai).*(r4(ai)+((-1).^(4+1)).*C4(ai))))-(C4(ai)./(r4(ai).*(r4(ai)+d4(ai))))))))
The calculations on the right hand side do not use x or y, so whatever it returns is not going to be the same size as x and y
The function you pass into integral2() is not passed scalar x and y: it is passed arrays of x and y that are the same size, and it is responsible for returning a result that is the same size as x.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by