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

2 views (last 30 days)
Ying Wu
Ying Wu on 7 Oct 2021
Commented: Star Strider on 7 Oct 2021
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!

Accepted Answer

Star Strider
Star Strider on 7 Oct 2021
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 Comments

Sign in to comment.

More Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by