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

4 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Star Strider
Star Strider il 7 Ott 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 Commenti
Ying Wu
Ying Wu il 7 Ott 2021
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!

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by