plot 3D grid using mesh() with lack of individual data

조회 수: 3 (최근 30일)
Ying Wu
Ying Wu 2021년 10월 7일
댓글: Star Strider 2021년 10월 7일
Hi, I want to use mesh to plot 3D grids with the format of mesh(x, y, z). My z is a 47*11 matrix, in which the 7 column actually has only 45 values, and I set the other 2 numbers as NaN in order to from a matrix with other columns. But when I plot the figure, the location of NaN is blank (see below).
Is there any method to fill these special locations? Thanks!

채택된 답변

Star Strider
Star Strider 2021년 10월 7일
It would be best to have your data, however an illustration of the procedure using the fillmissing function is — .
x = 1:11;
y = 1:47;
z = y(:)*x
z = 47×11
1 2 3 4 5 6 7 8 9 10 11 2 4 6 8 10 12 14 16 18 20 22 3 6 9 12 15 18 21 24 27 30 33 4 8 12 16 20 24 28 32 36 40 44 5 10 15 20 25 30 35 40 45 50 55 6 12 18 24 30 36 42 48 54 60 66 7 14 21 28 35 42 49 56 63 70 77 8 16 24 32 40 48 56 64 72 80 88 9 18 27 36 45 54 63 72 81 90 99 10 20 30 40 50 60 70 80 90 100 110
figure
mesh(x, y, z)
grid on
title('Original')
z(20:25,5:7) = NaN; % Create Gaps
figure
mesh(x, y, z)
grid on
title('With Gaps')
z = fillmissing(z, 'linear');
figure
mesh(x, y, z)
grid on
title('Interpolated')
.
  댓글 수: 2
Ying Wu
Ying Wu 2021년 10월 7일
That's exactly what I want! Thank you soooo much~! I find the "linear" method is to replace the missing data with the average value of the two data points around it. That makes sense. Thanks again!
Star Strider
Star Strider 2021년 10월 7일
As always, my pleasure!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by