I need to smooth a 3d graph

조회 수: 4 (최근 30일)
Shayleah Gunning-Lavoie
Shayleah Gunning-Lavoie 2022년 11월 26일
댓글: 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)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by