現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
Warning: Non-finite result. The integration was unsuccessful. Singularity likely.
9 ビュー (過去 30 日間)
古いコメントを表示
Hi i run a code thta include two doyble integration i recieve e message Warning: Non-finite result. The integration was unsuccessful.
but the final resulta are finite what happen ? the results are reliably ?
the main code is
currentMoM()
f = 300000000
N = 40
ra = 1
k0 = 6.2832
Z0 = 376.9911
lambda = 1
ans = NaN + NaNi
Warning: Non-finite result. The integration was unsuccessful. Singularity likely.
ans = NaN + NaNi
Unrecognized function or variable 'Efieldin'.
Error in solution>@(x)(4./(Z0.*k0)).*triangle_basisn(x,index_i).*Efieldin(x) (line 37)
func=@(x)(4./(Z0.*k0)).*triangle_basisn(x,index_i).*Efieldin(x);
Error in integralCalc>iterateScalarValued (line 334)
fx = FUN(t);
Error in integralCalc>vadapt (line 148)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen, ...
Error in integralCalc (line 77)
[q,errbnd] = vadapt(vfunAB,interval, ...
Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
Error in solution>currentMoM (line 38)
gm(index_i) =integral(func,Phi0(index_i),Phi0(index_i)+2*pi/N);
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;
for jj = 1:N
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
funa = @(x,y)triangle_basisn(x,index_i).*triangle_basisn(y,index_j).*ra.*(1-j.*(2/pi).*log((gamma_const./2).*k0.*ra.*sqrt(2-2.*cos(x-y)))) ;
funa(Phi0(index_i),Phi0(index_j))
lmn(index_i,index_j) =integral2(funa,Phi0(index_i),Phi0(index_i)+2*pi/N,Phi0(index_j),Phi0(index_j)+2*pi/N);
lmn(index_i,index_j)
else
funb = @(x,y)triangle_basisn(x,index_i).*triangle_basisn(y,index_j).*ra.*besselh(0,2,k0.*ra.*sqrt(2-2.*cos(x-y)));
lmn(index_i,index_j) =integral2(funb,Phi0(index_i),Phi0(index_i)+2*pi/N,Phi0(index_j),Phi0(index_j)+2*pi/N);
func=@(x)(4./(Z0.*k0)).*triangle_basisn(x,index_i).*Efieldin(x);
gm(index_i) =integral(func,Phi0(index_i),Phi0(index_i)+2*pi/N);
zmn(index_i,index_j) = lmn(index_i,index_j) ;
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
end
W = linsolve(zmn,gm');
for ii=1:N
Is(ii)=W(ii);
end
y= Is;
end
function [f,N,ra,k0,Z0,lambda] = parameter()
%UNTITLED Summary of this function goes here
c0=3e8;
Z0=120.*pi;
ra=1;
N=40;
f=300e6;
lambda=c0./f;
k0=2*pi./lambda;
end
function z=triangle_basisn(phi,kk)
[~,N,ra,k0,Z0,lambda] = parameter();
%Phin=zeros(N)
dftm=2.*pi./N;
%for jj = 1:N+1
%Phi0(jj)=(jj-1).*dftm;
%end
%Phin=Phi0
if ( phi >=(kk-1).*dftm ) & ( phi <=kk.*dftm);
z=(phi-(kk-1).*dftm)./dftm;
elseif (phi >= kk.*dftm) & (phi <= (kk+1).*dftm);
z=((kk+1).* dftm -phi)./dftm;
else
z=0 ;
end
end
thank you
Goerge
32 件のコメント
Torsten
2024 年 11 月 29 日
Did you make any changes to your old code ? The same problem remained (see above).
Your function becomes NaN for
funa(Phi0(index_i),Phi0(index_j))
Torsten
2024 年 11 月 30 日
編集済み: Torsten
2024 年 11 月 30 日
In the computation of zmn, results from the case index_i = index_j (thus the case where NaN results are computed) are not used. Thus - although you get the warning: Non-finite result. The integration was unsuccessful, your results for Is might be reliable. Which raises the question: why do you compute lmn for index_i = index_j as below
if index_i == index_j
funa = @(x,y)triangle_basisn(x,index_i).*triangle_basisn(y,index_j).*ra.*(1-j.*(2/pi).*log((gamma_const./2).*k0.*ra.*sqrt(2-2.*cos(x-y)))) ;
lmn(index_i,index_j) =integral2(funa,Phi0(index_i),Phi0(index_i)+2*pi/N,Phi0(index_j),Phi0(index_j)+2*pi/N);
at all if the result is nowhere used ?
george veropoulos
2024 年 11 月 30 日
hi
the element of z or l matrix with index_i == index_j are the diagonal element
in this cace i use a small approximation (1-j.*(2/pi).*log(A.*sqrt(2-2.*cos(x-y))))
of Hankel function besselh(0,2,kR)
Torsten
2024 年 11 月 30 日
But you never write the results of the integration for index_i = index_j into the zmn matrix which is used to compute Is. So zmn(i,i) (the diagonal) remains at its initial values given to them by preallocation:
zmn = zeros(N);
george veropoulos
2024 年 11 月 30 日
編集済み: Torsten
2024 年 11 月 30 日
You are write.. i use an approximation diagonal teem log(A)+log(x-y+1e-6) i add a small number
idont receive any message from integral but receive a warning from matrix "Matrix is singular to working precision"
currentMoM()
f = 300000000
N = 40
ra = 1
k0 = 6.2832
Z0 = 376.9911
lambda = 1
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
ans =
Columns 1 through 9
0.0031 + 0.0015i 0.0023 + 0.0014i 0.0011 + 0.0010i 0.0001 + 0.0003i -0.0004 + 0.0000i -0.0011 + 0.0005i -0.0025 + 0.0007i -0.0035 - 0.0007i -0.0019 - 0.0026i
Columns 10 through 18
0.0019 - 0.0023i 0.0042 + 0.0012i 0.0024 + 0.0046i -0.0016 + 0.0041i -0.0036 + 0.0000i -0.0022 - 0.0044i 0.0012 - 0.0064i 0.0042 - 0.0059i 0.0057 - 0.0042i
Columns 19 through 27
0.0061 - 0.0027i 0.0061 - 0.0019i 0.0061 - 0.0020i 0.0061 - 0.0031i 0.0054 - 0.0048i 0.0033 - 0.0063i 0.0000 - 0.0060i -0.0030 - 0.0031i -0.0033 + 0.0016i
Columns 28 through 36
-0.0003 + 0.0048i 0.0034 + 0.0038i 0.0038 - 0.0002i 0.0006 - 0.0028i -0.0027 - 0.0021i -0.0034 - 0.0000i -0.0020 + 0.0007i -0.0008 + 0.0003i -0.0003 + 0.0001i
Columns 37 through 40
0.0004 + 0.0006i 0.0015 + 0.0012i 0.0026 + 0.0015i 0.0032 + 0.0015i
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;
for jj = 1:N
Phi0(jj)=(jj-1).*dftm;
end
lmn = zeros(N,N);
gm = zeros(1,N);
zmn = zeros(N,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
A=(gamma_const./2).*k0.*ra ;
%funa = @(x,y)triangle_basisn(x,index_i).*triangle_basisn(y,index_j).*ra.*(1-j.*(2/pi).*ra.*(1-j.*(2/pi).*ra.*log(A.*sqrt(2-2.*cos(x-y))))) ;
funa = @(x,y)triangle_basisn(x,index_i).*triangle_basisn(y,index_j).*ra.*(1-j.*(2/pi).*(log(A)+log(x-y+1e-8)));
lmn(index_i,index_j) =integral2(funa,Phi0(index_i),Phi0(index_i)+2*pi/N,Phi0(index_j),Phi0(index_j)+2*pi/N);
zmn(index_i,index_j) = lmn(index_i,index_j) ;
else
funb = @(x,y)triangle_basisn(x,index_i).*triangle_basisn(y,index_j).*ra.*besselh(0,2,k0.*ra.*sqrt(2-2.*cos(x-y)));
lmn(index_i,index_j) =integral2(funb,Phi0(index_i),Phi0(index_i)+2*pi/N,Phi0(index_j),Phi0(index_j)+2*pi/N);
zmn(index_i,index_j) = lmn(index_i,index_j) ;
func=@(x)triangle_basisn(x,index_i).*(4./(Z0.*k0)).*Efieldin(x);
gm(index_i) =integral(func,Phi0(index_i) ,Phi0(index_i)+2*pi/N);
end
end
end
W = linsolve(zmn,gm');
for ii=1:N
Is(ii)=W(ii);
end
y= Is;
end
function [f,N,ra,k0,Z0,lambda] = parameter()
%UNTITLED Summary of this function goes here
c0=3e8;
Z0=120.*pi;
ra=1;
N=40;
f=300e6;
lambda=c0./f;
k0=2*pi./lambda;
end
function z=triangle_basisn(phi,kk)
[~,N,ra,k0,Z0,lambda] = parameter();
%Phin=zeros(N)
dftm=2.*pi./N;
%for jj = 1:N+1
%Phi0(jj)=(jj-1).*dftm;
%end
%Phin=Phi0
if ( phi >=(kk-1).*dftm ) & ( phi <=kk.*dftm);
z=(phi-(kk-1).*dftm)./dftm;
elseif (phi >= kk.*dftm) & (phi <= (kk+1).*dftm);
z=((kk+1).* dftm -phi)./dftm;
else
z=0 ;
end
end
function z=Efieldin(phi)
%amplitude
[f,N,ra,k0,Z0] = parameter();
E0=1;
%z=E0.*exp(j.*k0.*ra.*cos(phi)+j.*k0.*ra.*sin(phi));
z=E0.*exp(j.*k0.*ra.*cos(phi));
end
Torsten
2024 年 11 月 30 日
編集済み: Torsten
2024 年 11 月 30 日
idont receive any message from integral but receive a warning from matrix "Matrix is singular to working precision"
In R2024b, I get many warning that some of the integrals could not be computed reliably, but no warning about a matrix that is singular to working precision (see above). Do we use the same code ? What MATLAB release are you working with ?
george veropoulos
2024 年 11 月 30 日
i receive the same message ... but also this the message with matrix i use 2024a
Torsten
2024 年 11 月 30 日
It seems you try to integrate a discontinuous function. This will almost always fail.
if ( phi >=(kk-1).*dftm ) & ( phi <=kk.*dftm);
z=(phi-(kk-1).*dftm)./dftm;
elseif (phi >= kk.*dftm) & (phi <= (kk+1).*dftm);
z=((kk+1).* dftm -phi)./dftm;
else
z=0 ;
end
george veropoulos
2024 年 11 月 30 日
if i remove the function triangle_basisn i receive the same message !!
Torsten
2024 年 11 月 30 日
I understand that your computation doesn't succeed. And I gave you the most probable reason: the function you try to integrate is discontinuous. There can be other reasons: there is an error in your code, the parameters are too extreme and so on.
If I were you, I'd first make a surface plot of the real and imaginary parts of the functions you try to integrate and this way find out where "integral2" might encounter problems.
george veropoulos
2024 年 11 月 30 日
i set triangle_basisn(phi,kk) equal to 1 . Ι receive problem from the integral in funa with the log singularity!
george veropoulos
2024 年 11 月 30 日
Warning: Reached the maximum number of function evaluations (10000). The
result fails the global error test.
> In integral2Calc>integral2t (line 139)
In integral2Calc (line 9)
In integral2 (line 105)
In currentMoM (line 31)
this is the line 31
funa = @(x,y)triangle_basisn(x,index_i).*triangle_basisn(y,index_j).*ra.*(1-j.*(2/pi).*(log(A)+log(x-y+1e-9)));
Torsten
2024 年 11 月 30 日
編集済み: Torsten
2024 年 12 月 1 日
Of course you can do a Monte-Carlo integration. But if you change the integration method, the mathematical problem about the integrand won't vanish. In the Monte-Carlo integration, the problem will show up that you don't get a converged solution for the integral for an increasing number of random test points.
george veropoulos
2024 年 12 月 1 日
移動済み: Torsten
2024 年 12 月 1 日
this integral come out from the method of moment in EM...
Torsten
2024 年 12 月 1 日
編集済み: Torsten
2024 年 12 月 1 日
The white diagonal seems to indicate that you get NaN values for x = y.
And the varying colors between green and blue show discontinuous behaviour ?
I think you have no chance to integrate this function with a numerical method.
EM is ElectroMagnetism ?
Torsten
2024 年 12 月 1 日
Do you have a literature link where this integral is written out in a mathematical way ?
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)