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)

 採用された回答

per isakson
per isakson 2012 年 8 月 8 日

0 投票

Are there NaN in either C or y? Try
any( isnan( C ) )
any( isnan( y ) )

3 件のコメント

Tanaya
Tanaya 2012 年 8 月 8 日
>> 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 2012 年 8 月 8 日
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 2012 年 8 月 8 日
I used an even discretization value and started from an odd number so it never solves at zero! Thanks for pointing out the NaN.

サインインしてコメントする。

その他の回答 (1 件)

Matt Fig
Matt Fig 2012 年 8 月 8 日
編集済み: Matt Fig 2012 年 8 月 8 日

0 投票

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....

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by