Warning: Non-finite result. The integration was unsuccessful. Singularity likely. > In integral2Calc>integral2t (line 131)
Ältere Kommentare anzeigen
Hi
i run the function
[Is]=currentMoM()
function [Is]=currentMoM()
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
[f,N,ra,k0,Z0,lambda] = parameter()
gamma_const=1.781;
Phi0=zeros(N);
e=exp(1);
dftm=2.*pi./(N-1);
for jj = 1:N+1
Phi0(jj)=(jj-1).*dftm;
end
% delta_c(i) = sqrt((pos(i,1) - pos(i+1,1))^2 + (pos(i,2) - pos(i+1,2))^2);
lmn = zeros(N);
%zmn = zeros(N);
gm = zeros(1,N);
zmn = zeros(N);
%vim = zeros(1,N);
%vsn = zeros(1,N);
coeif=(Z0.*k0./4).*ra.*dftm;
coeifn=(Z0./2).*sin(k0.*ra.*dftm./2);
for index_i = 1:N
for index_j = 1:N
if index_i == index_j
fun = @(x,y)triangle_basisn(x,index_i).*triangle_basisn(y,index_j).*ra.*(1-j.*(2/pi).*log(gamma_const.*k0.*ra*sqrt(2-2*cos(x-y))./2));
reason_for_failure = fun(Phi0(index_i),Phi0(index_j))
lmn(index_i,index_j) =integral2(fun, Phi0(index_i),Phi0(index_i)+2*pi./(N-1),Phi0(index_j),Phi0(index_j)+2*pi./(N-1));
else
fun = @(x,y)triangle_basisn(x,index_i).*triangle_basisn(y,index_j).*ra.^2.*besselh(0,2,k0.*ra*sqrt(2-2*cos(x-y)));
lmn(index_i,index_j) =integral2(fun,Phi0(index_i),Phi0(index_i)+2*pi./(N-1),Phi0(index_j),Phi0(index_j)+2*pi./(N-1));
zmn(index_i,index_j) = lmn(index_i,index_j);
fun=@(x)triangle_basisn(x,index_i).*(4./(Z0.*k0)).*Efieldin(x);
gm(index_i) =integral(fun,Phi0(index_i),Phi0(index_i)+2*pi./(N-1));
end
%vim(index_i) = delta_c(index_i) * exp(j*k0*(xm(index_i)*cos(phi_i)+ym(index_i)*sin(phi_i)));
%vsn(index_i) = delta_c(index_i) * exp(j*k0*(xm(index_i)*cos(phi_s)+ym(index_i)*sin(phi_s)));
end
W = linsolve(zmn,gm');
for ii=1:N
Is(ii)=W(ii);
end
y= Is
end
end
i use the integral2 and i recieve the message Warning: Non-finite result. The integration was unsuccessful. Singularity likely.
> In integral2Calc>integral2t (line 131)
what happen?
also i use the following function
function z=triangle_basisn(phi,kk)
[f,N,ra,k0,Z0,lambda] = parameter();
dftm=2.*pi./(N-1);
for jj = 1:N+1
Phi0(jj)=(jj-1).*dftm;
end
Phin=Phi0;
if kk==1
z=phi./dftm;
elseif ( phi >= Phin(kk-1) ) & ( phi <=Phin(kk));
z=(phi-Phin(kk-1))./dftm;
elseif (phi >= Phin(kk) ) & (phi <=Phin(kk+1));
z=(Phin(kk+1)-phi)./dftm;
end
end
function [f,N,ra,k0,Z0,lambda] = parameter()
%UNTITLED Summary of this function goes here
c0=3e8;
Z0=120.*pi;
ra=1;
N=39;
f=300e6;
lambda=c0./f;
k0=2*pi./lambda;
end
tnak you
Antworten (1)
Torsten
am 25 Nov. 2024
fun(Phi0(1),Phi0(1))
gives
NaN + 1i*NaN
11 Kommentare
george veropoulos
am 25 Nov. 2024
Verschoben: Torsten
am 25 Nov. 2024
george veropoulos
am 25 Nov. 2024
george veropoulos
am 25 Nov. 2024
Verschoben: Torsten
am 25 Nov. 2024
The point (0,0) is still within the box of integration - thus the problem remains.
And since your if-statement in "triangle_basisn" only handles non-negative values for phi, a value for z is not assigned for an integrational box that contains negative numbers.
Walter Roberson
am 25 Nov. 2024
if kk==1
z=phi./dftm;
elseif ( phi >= Phin(kk-1) ) & ( phi <=Phin(kk));
z=(phi-Phin(kk-1))./dftm;
elseif (phi >= Phin(kk) ) & (phi <=Phin(kk+1));
z=(Phin(kk+1)-phi)./dftm;
end
If none of the if or elseif conditions are met, then z is not assigned to.
If you treat z as piecewise constant on intervals for Phin as you do in "triangle_basisn", you shouldn't use "integral2".
"integral2" is meant to be used for functions that depend continuously on the independent variable.
In your case, using "trapz" twice is the better choice (after having healed the NaN problem at (0,0)).
Take a look at the example
"Multiple Numerical Integrations"
under
george veropoulos
am 26 Nov. 2024
Bearbeitet: Walter Roberson
am 26 Nov. 2024
george veropoulos
am 26 Nov. 2024
Bearbeitet: Walter Roberson
am 26 Nov. 2024
sorrry i receive the same message
Output argument "z" (and possibly others) not assigned a value in the execution with "triangle_basisn"
function.
Did you read @Walter Roberson 's and my comment ? Negative values of the independent variable phi are not covered in your if-statement, and thus no value is assigned to z:
if kk==1
z=phi./dftm;
elseif ( phi >= Phin(kk-1) ) & ( phi <=Phin(kk));
z=(phi-Phin(kk-1))./dftm;
elseif (phi >= Phin(kk) ) & (phi <=Phin(kk+1));
z=(Phin(kk+1)-phi)./dftm;
end
george veropoulos
am 26 Nov. 2024
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!