I need to smooth a 3d graph

6 ビュー (過去 30 日間)
Shayleah Gunning-Lavoie
Shayleah Gunning-Lavoie 2022 年 11 月 26 日
this is tha data I have now and i need to smooth it out thank you! there is no errors or red text in the following code
x=1:10;
y=1:21;
z=[0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 -9 0 0 0 0; 0 0 0 0 -5 -7 0 0 0 0; 0 0 -10 -25 -15 -5 0 0 0 0; 0 -20 -32 -46 -27 -7 0 0 0 0; 0 -17 -61 -82 -21 0 0 0 0 0; 0 -12 -28 -52 -30 -12 0 0 0 0; 0 -22 -43 -79 -53 -30 -12 0 0 0; 0 -15 -38 -63 -92 -68 -33 0 0 0; 0 0 -15 -37 -61 -49 -22 0 0 0; 0 0 0 -17 -56 -30 -17 0 0 0; 0 0 0 -15 -56 -30 -17 0 0 0; 0 0 -15 -32 -54 -94 -79 -31 0 0; 0 0 -21 -15 -25 -52 -37 -20 0 0; 0 0 -15 -40 -70 -49 -20 -15 0 0; 0 0 -11 -23 -14 -20 -46 -29 -14 0; 0 0 0 -10 -27 -39 -25 -15 0 0; 0 0 0 -15 -32 -56 -26 -10 0 0; 0 0 0 -10 -17 -25 -15 0 0 0; 0 0 0 0 -20 -10 0 0 0 0; 0 0 0 0 -5 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0];
surf(z);

回答 (1 件)

John D'Errico
John D'Errico 2022 年 11 月 26 日
x=1:10;
y=1:21;
z=[0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 -9 0 0 0 0; 0 0 0 0 -5 -7 0 0 0 0; 0 0 -10 -25 -15 -5 0 0 0 0; 0 -20 -32 -46 -27 -7 0 0 0 0; 0 -17 -61 -82 -21 0 0 0 0 0; 0 -12 -28 -52 -30 -12 0 0 0 0; 0 -22 -43 -79 -53 -30 -12 0 0 0; 0 -15 -38 -63 -92 -68 -33 0 0 0; 0 0 -15 -37 -61 -49 -22 0 0 0; 0 0 0 -17 -56 -30 -17 0 0 0; 0 0 0 -15 -56 -30 -17 0 0 0; 0 0 -15 -32 -54 -94 -79 -31 0 0; 0 0 -21 -15 -25 -52 -37 -20 0 0; 0 0 -15 -40 -70 -49 -20 -15 0 0; 0 0 -11 -23 -14 -20 -46 -29 -14 0; 0 0 0 -10 -27 -39 -25 -15 0 0; 0 0 0 -15 -32 -56 -26 -10 0 0; 0 0 0 -10 -17 -25 -15 0 0 0; 0 0 0 0 -20 -10 0 0 0 0; 0 0 0 0 -5 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0];
surf(z)
Simplest is a convolution based blur. This one is a simple distance weighting:
n = 3;
n2 = (n-1)/2;
[x,y] = meshgrid((1:n) - n2);
K = 1./(1 + sqrt((x - n2).^2 + (y - n2).^2));
K = K/sum(K,'all')
K = 3×3
0.0889 0.1074 0.0889 0.1074 0.2147 0.1074 0.0889 0.1074 0.0889
zhat = conv2(K,z)./conv2(ones(size(z)),K);
surf(zhat)
  1 件のコメント
Shayleah Gunning-Lavoie
Shayleah Gunning-Lavoie 2022 年 11 月 26 日
Thank you!

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by