필터 지우기
필터 지우기

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 CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by