How to smooth a contour plot?

16 ビュー (過去 30 日間)
Josh
Josh 2014 年 2 月 27 日
コメント済み: James Zhang 2020 年 7 月 31 日
I have:
  • vector X: legnth(X)=90 --> X=[0:0.0125:1.1125]
  • vector Y: length(Y)=80 --> Y=[22.2: ...(not periodic)... :4]
  • matrix Z: size(Z)=90,80 --> measured values from each (X,Y) simulation
I am using contour(X,Y,Z), but am getting jagged, non-smooth contour lines, like this:
How do I smooth the contour lines? I've fiddled with trying to use interp2, but am falling down on the use of grid inputs I think.
Any help is much appreciated.

採用された回答

John D'Errico
John D'Errico 2014 年 2 月 27 日
You DON'T want to smooth the contour lines. That just never works out. Better (but rarely perfect) is to smooth the surface before the contours are built. I say not perfect because any time you do smoothing, you lose information too. Hey, life is tough.
The simple way to smooth the surface is to just use conv2, with a Gaussian blur as a kernel. Choose the width of the gaussian to adjust the amount of smoothing.
You can also use my gridfit code from the file exchange, which allows a choice of the smoothing parameter, thus the amount of smoothing.
  1 件のコメント
James Zhang
James Zhang 2020 年 7 月 31 日
Life is tough!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by