Smooth contours of a colormap
5 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have an mxn matrix and i am plotting a filled contour map.
tbl=[360, 365, 400, 430, 470, 495, 535, 565, 585, 620, 620, 660;365, 400, 400, 465, 495, 515, 540, 565, 585, 620, 620, 350;400, 405, 465, 470, 495, 515, 555, 565, 585, 355, 355, 360;430, 465, 480, 495, 515, 540, 565, 565, 360, 360, 360, 365;480, 490, 505, 515, 540, 565, 565, 360, 365, 365, 370, 390;510, 530, 555, 560, 565, 565, 365, 365, 370, 390, 400, 405;560, 565, 575, 580, 585, 585, 370, 390, 400, 415, 425, 440;590, 590, 595, 595, 595, 595, 595, 410, 425, 445, 460, 475;625, 625, 635, 655, 655, 655, 655, 625, 465, 485, 485, 500;675, 675, 690, 690, 690, 690, 690, 690, 590, 520, 520, 550;705, 705, 705, 705, 705, 705, 705, 705, 705, 570, 570, 570;755, 755, 755, 770, 770, 770, 770, 770, 755, 705, 600, 600]
x=[0:5:55];
y=[0:5:55];
contourf(x,y,tbl)
shading flat
I would like the contours to be smooth which is not the case, I have to interpolate but how can I build the X and Y matrix to use the interp2 function ?
tbl is an intensity at the point (x,y).
Thanks
回答 (1 件)
Bjorn Gustavsson
2019 年 5 月 15 日
Why do you want your contours to be smooth? You have some idea that the surface doesn't have corner-like edges where slopes in different directions connect - how are we to know what's suitable smoothing when we only see the 12 x 12 data points you have?
You could try to interpolate your data:
xi = 0:.5:55;
yi = 0:.5:55;
tbli = interp2(x,y,tbl,xi,yi','cubic'); % try 'linear' too...
contour(xi,yi,tbli)
or if you have the spline-toolbox you could try more advanced interpolation or fitting functions. You could also use:contour-line-smooting, or Contour-line-smooting-local-regression. But those are not guaranteed to give you the results
you wish...
HTH
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Contour Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!