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 - The Fusion of Science and Community**

Join Physics Forums Today!

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

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

Loading...

Similar Threads - Matlab code independent | Date |
---|---|

I No memory superdense coding | Jun 12, 2017 |

I How to turn model of Schrödinger's Equation 2D? | Sep 3, 2016 |

Computing normalized oscillator states for very large N (Matlab) | Jun 27, 2014 |

Problem regarding Matlab code for n no of quantum well | Dec 21, 2011 |

A question about solving Schrodinger equation with eigs() in Matlab | Aug 27, 2010 |

**Physics Forums - The Fusion of Science and Community**