Piecewise function using sign
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
I'm trying to solve a schrodinger equation for a particle in an asymmetrical potential well, I found a way to do it with Chebfun, but I fail to define the piecewise potential.
The potential is:
- For x smaller than 0, V(x)=inf
- For x in [0,a), V(x)=0
- For x in (a,b], V(x)=-V0
- For x larger than b, V(x)=inf
I'm trying to define V in a similar way to this;
x = chebfun('x',[-a,a+b]);
V = 80*(sign(x+1)-0.8*sign(x-0.9));
Is this possible with sign for a 4-piece function?
Antworten (1)
Walter Roberson
am 24 Jan. 2018
0 Stimmen
the inf makes this difficult. For finite values you can take (condition)*value which will be 0*value = 0 for finite values when the condition is false, but when value is infinite that is 0*inf which is NaN, and the NaN poisons everything else.
You can get at inf for a condition by taking 1/(~condition) to get 1/0 when the condition is true.
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!