Why is there a jagged line when I plot this function?
古いコメントを表示
Hi guys,
I am trying to plot an implicit function and am getting strange results. I understand the smooth part of the function, but not the jagged part. Why is the jagged part there at all? Also, what can I do to eliminate it?
Here's the code:
f1=(@(x,y) (5.*y.^(1./2) -3)./(2.5.*y.^(1./2)+2.5.*x.^(1./2)-3)-y);
fimplicit(f1,[0 4 0 4],'black')
回答 (2 件)
tmarske
2020 年 3 月 16 日
It's because fimplicit is using too few evaluation points, resulting in too coarse an interpolation (by default it uses 151). You can override this using the 'MeshDensity' argument:
f1=(@(x,y) (5.*y.^(1./2) -3)./(2.5.*y.^(1./2)+2.5.*x.^(1./2)-3)-y);
fimplicit(f1,[0 4 0 4],'black', 'MeshDensity', 5000)
6 件のコメント
econogist
2020 年 3 月 16 日
Walter Roberson
2020 年 3 月 16 日
What would you expect the result to look like? There are two lower-branch solutions for each x, and at some point they become equal and cross; what would you discard?
econogist
2020 年 3 月 16 日
Walter Roberson
2020 年 3 月 17 日
Ah, what is happening is that your function has a discontinuity in it, and what fimplicit is detecting is not a zero but rather a sign change.
econogist
2020 年 3 月 17 日
Walter Roberson
2020 年 3 月 17 日
編集済み: Walter Roberson
2020 年 3 月 17 日
If you have the symbolic toolbox, you can solve f1 for x in term of y to get a single x for each y. you can then linspace() for y and put those through the equation to derive x, and then plot(x,y)
econogist
2020 年 3 月 17 日
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!