Numerical volume integral with keeping parameters

조회 수: 1 (최근 30일)
dont panic
dont panic 2013년 9월 9일
HI ,
I wanted to calculate the magnetic potential of a bar magnet by numerical integration of the potential of a point source over the volume of the magnet. Below is my source code but I always get an error message.
Thank you for your help
a=0.0025; L=0.005; phis=0;
r1=0; r2=a; phi1=0; phi2=2*pi; z1=-L/2; z2=L/2;
%Function
f=@(r,phi,z,R,Z) (sin(phis-phi).*r)/(R.^2-2.*r.*R.*cos(phis-phi)+r.^2+(Z-z).^2).^(3/2);
[R,Z] = meshgrid(-0.05:s:0.05); mp=zeros(size( R ));
for k = 1:numel( R )
g = @(r,phi,z) f(r,phi,z,R(k),Z(k));
mp(k) = triplequad(g,r1,r2,phi1,phi2,z1,z2);
end
surf(R,Z,mp)

답변 (1개)

Mike Hosea
Mike Hosea 2013년 9월 11일
Well, for starters, you need to change / to ./ in the definition of f. Second, however, you will need to use integral3 instead of triplequad.
  댓글 수: 2
dont panic
dont panic 2013년 9월 11일
Thank you for your answer but I am using Matlab 2011a and as far as I can see matlab 2011a has no such ability. (but i might as well be wrong as i am new but the funktion browser had no entry for integral3 ) Is there a possibility to solve the problem with Matlab 2011a ?
thanks in advance
Mike Hosea
Mike Hosea 2013년 9월 11일
Sorry, on second thought, you may not need INTEGRAL3. When I ran this, all I got were answers that numerically were not distinguishable from zero, and there is a singularity when R=0 and Z=0. There must be something wrong with your formulation.

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

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by