Hello, I'm trying to solve a time independent schrodinger equation with matlab. i wish to write a function whose inputs are Energy, X and potential U and the output must be the wave function Psi of that point. Here's my code but I don't know which Psi (which index i) is the Psi I want. Please help. thanks in advance :)(adsbygoogle = window.adsbygoogle || []).push({});

function [Psi] = Schro1D(E, X, U)

hbar = 1.05457148 * 10^-34;

mzero = 9.10938188 * 10^-31;

eV = 1.60217646E-19;

nL = length(X);

L = X(length(X));

dX = L/nL;

E = E*eV;

Kx = sqrt((2*mzero*(E-U)))/hbar;

Psi_one = zeros(1,length(X));

Psi_one(nL) = exp(1i*Kx(nL)*L);

Psi_one(nL+1) = exp(1i*Kx(nL)*(L+dX));

for i = nL-1:-1:2

Psi_one(i-1) = Psi_one(i)*(2-(Kx(i)*dX)^2)-Psi_one(i+1);

end

plot(X,(Psi_one(:,3))');

end

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab code for time-independent schrodinger equation

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

**Physics Forums | Science Articles, Homework Help, Discussion**