When integrating numerically with integral2, the integral function contains a sign variable, causing the integral to keep reporting an error.
이전 댓글 표시
B is a vector expression with three directions ex, ey and ez, and each component has a double integral.I want to figure out the magnitude of B.So when we do double integrals, because we have A lot of repetitive code, we'll use A instead And then there was an error. If you type it directly, it can run.I want to know if integral2 can't have signed variables in its integral function, and if not, how can I modify it. Or how can the program be optimized?
syms phii rr theta r;
format short
phi = pi./2;
R = 0.05;
A = (((r.*sin(theta)-rr.*sin(phii)).^2+r.^2.*cos(theta).^2+rr.^2.*cos(phii).^2).^(3./2));
B = [];
for theta = [0,pi/6,pi/4,pi/3,pi/2]
Ix = []; % direction of ex
for r = 0.06:0.001:0.09
fx = @(rr,phii) rr.*r.*cos(theta).*cos(phii)./A;
ex = integral2(fx,0,R,0,2*pi);
Ix = [Ix,ex];
end
Iy = []; % direction of ey
for r = 0.06:0.001:0.09
fy = @(rr,phii) rr.*r.*cos(theta).*sin(phii)./A;
ey = integral2(fy,0,R,0,2*pi);
Iy = [Iy,ey];
end
Iz = []; % direction of ez
for r = 0.06:0.001:0.09
fz = @(rr,phii) rr.*(rr-r.*sin(phii).*sin(theta))./A;
ez = integral2(fz,0,R,0,2*pi);
Iz = [Iz,ez];
end
Bb = sqrt((Ix.^2+Iy.^2+Iz.^2)); % B
B = [B;Bb];
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Tuning Goals에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!