Why are there gaps in some of my plots?

Hello
I'm plotting a simple equation that seems to be producing the plot I want but is not displaying a continuous line. Its plotting as some kind of discontinuous step function, whereas, I would it to plot the step as a continuos line. I've tried changing the discretization of y, but that doesn't seem to help. Any other thoughts or suggestions would be greatly appreciated. Thanks in advance!
Here is a simplified version of my code:
x2=0;
D=1.003807*10^-7;
u=0.0077;
y=-0.11:0.0001:0.11;
C=(1/2).*(1+erf(y./(sqrt(4*D*x2/u))));
figure
plot(C,y)

 Respuesta aceptada

per isakson
per isakson el 8 de Ag. de 2012
Are there NaN in either C or y? Try
any( isnan( C ) )
any( isnan( y ) )

3 comentarios

>> any( isnan( C ) )
any( isnan( y ) )
ans =
1
ans =
0
Good call. Any ideas on how I can get around this?
Matt Kindig
Matt Kindig el 8 de Ag. de 2012
Since x2=0, the sqrt() term will always be zero, so the y./sqrt() term will always yield Inf. You will notice that your C is always 0, 1, or NaN. Is this the intended result?
Tanaya
Tanaya el 8 de Ag. de 2012
I used an even discretization value and started from an odd number so it never solves at zero! Thanks for pointing out the NaN.

Iniciar sesión para comentar.

Más respuestas (1)

Matt Fig
Matt Fig el 8 de Ag. de 2012
Editada: Matt Fig el 8 de Ag. de 2012
You have nans in your data because of this:
x2=0;
D=1.003807*10^-7;
u=0.0077;
y=-0.11:0.0001:0.11;
T = sqrt(4*D*x2/u); % Look at this one!
unique(T) % You are dividing by zero in V
V = y./(T); % Look at this!
unique(V)
C=(1/2).*(1+erf(V));
.
.
So, why is T all zeros? Look at x2....

Categorías

Etiquetas

Preguntada:

el 8 de Ag. de 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by