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 Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by