フィルターのクリア

Hello, I'm trying to plot a normalized wave function of a free particle. My problem is normalizing the function. But get nothin. I use the following values, (10,100,10,10)

3 ビュー (過去 30 日間)
function Vogfunktion(Dx, n, m,T)
V = 1;
h_bar = 1.054 * 10^-34;
x = linspace(0 , n*Dx, n);
F =zeros(1,n);
for i = 1:n
for E = 1:n
V = V + T*i;
k = sqrt(2*m*(E+V)/(h_bar^2));
psi_i = (sin(k*Dx*(i+1)) + sin(k*Dx*(i-1))/(2 + (Dx^2)* (2*m/h_bar^2)));
Norm = sqrt(1/trapz(psi_i));
if Norm ~= 0
F(i) = Norm;
end
end
end
plot(x,F)
ylim([-5,5]);
xlim([0,2*Dx*i]);
ylabel('psi')
xlabel('sträcka')

採用された回答

Walter Roberson
Walter Roberson 2023 年 12 月 11 日
psi_i = (sin(k*Dx*(i+1)) + sin(k*Dx*(i-1))/(2 + (Dx^2)* (2*m/h_bar^2)));
Unless your m is non-scalar, or your Dx is a non-scalar square array, then your psi_i would either error or return a scalar.
Norm = sqrt(1/trapz(psi_i));
trapz() of a scalar is 0. 1/0 is inf. sqrt(inf) is inf.
In order for 1/trapz(psi_1) to be 0 (following test) then the trapz() would have to return inf. You might be able to get NaN for psi_i (such as if Dx is inf then sin(inf) is NaN) but you would have a hard time getting inf out of there. So Norm is not going to be 0.
if Norm ~= 0
F(i) = Norm;
end
You are inside a for E loop but are assigning to F(i) . Except for the case where somehow some of the E values lead to Norm 0 (which would require that the trapz be inf) then you are overwriting all of F(i) for each E value, and the final result would be the same as if you had only executed the last for E iteration.

その他の回答 (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