Numerical integration over a variable

1 回表示 (過去 30 日間)
Özgür Alaydin
Özgür Alaydin 2021 年 11 月 10 日
回答済み: Walter Roberson 2021 年 11 月 10 日
Hello all
I have a function as given below and i want to integrate it over a variable but i am getting answer "V1=0".
However V1 can not be equal to "0" .
What is wrong?
Vb=0.450; dz=1e-10;
Ltot = 20e-9;
z=-Ltot/2:dz:Ltot/2;
L = 10e-9; a=2e-9; x=-L/2:dz/2:L/2;
f=Vb.*real(x./sqrt(a^2-(x-z).^2));
V1=trapz(~isnan(f),x)
V1 = 0

採用された回答

Walter Roberson
Walter Roberson 2021 年 11 月 10 日
trapz(x, y) is the syntax. If isnan is either always true or is never true for f then the "x" coordinates would all be the same (all true or all false, and in that case, the output would be mean() of the "y" coordinates. But your "y" coordinates are your x variable and that happens to be symmetrical around zero, so the mean is zero and your result is 0

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by