フィルターのクリア

Methods for smoothing contour lines

9 ビュー (過去 30 日間)
Andrew Sol
Andrew Sol 2022 年 10 月 20 日
コメント済み: Star Strider 2022 年 10 月 21 日
I have a database P with columns X, Y and Z (file above):
N = 150; % Number Of Points Desired
xv = linspace(min(P(:,1)), max(P(:,1)), N);
yv = linspace(min(P(:,2)), max(P(:,2)), N);
[X,Y] = ndgrid(xv, yv);
Z = griddata(P(:,1), P(:,2), P(:,3), X, Y);
contourf(X, Y, Z, 35)
Zi = interp2(P(:,1), P(:,2), P(:,3), X, Y) ;
With the code above, I get the following plot:
How to make contour lines neater and smoother?

採用された回答

Star Strider
Star Strider 2022 年 10 月 20 日
編集済み: Star Strider 2022 年 10 月 20 日
I dislike going to external sites.
Increasing ‘N’ would be the option I would use, initially experimenting with 250 and perhaps 500 or greater, depending on the available memory and the result provided. That should increase the resolution of the vectors, and therefore the resolution of the matrices derived from them.
EDIT — (20 Oct 2022 at 15:45)
Using the supplied data —
LD = load(websave('P','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1163343/P.mat'));
P = LD.P;
N = 500; % Number Of Points Desired
xv = linspace(min(P(:,1)), max(P(:,1)), N);
yv = linspace(min(P(:,2)), max(P(:,2)), N);
[X,Y] = ndgrid(xv, yv);
Z = griddata(P(:,1), P(:,2), P(:,3), X, Y);
Warning: Duplicate data points have been detected and removed - corresponding values have been averaged.
figure
contourf(X, Y, Z, 35)
I looked at the first column of ‘P’ to see if reshaping would work. It will not, because the first indices of the different unique values of ‘P(:,1)’ do not have constant distances between them.
The data simply do not appear to be smooth (i.e. may have limited precision), and that is reflected in the contours even with a relatively high precision in the interpolating matrices.
This is likely as good as it gets.
.
  18 件のコメント
Andrew Sol
Andrew Sol 2022 年 10 月 21 日
And thank you for not passing by!
Star Strider
Star Strider 2022 年 10 月 21 日
As always, my pleasure!
This was an interesting problem!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by