Piecewise function using sign
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
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?
Respuestas (1)
Walter Roberson
el 24 de En. de 2018
0 votos
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.
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!