Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab code for time-independent schrodinger equation

  1. Jun 29, 2012 #1
    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 :)

    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);

  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted