Fill polygon with NaN data

1 次查看(过去 30 天)
Pengfei
Pengfei 2012-11-3
Hi, I have data matrix with NaN, and I want to fill the polygon colored. It seemed Matlab cannot close the polygon automatically, thus wouldn't color it.
X_data =
[13.3596 16.1477
13.3596 16.1477
21.1457 17.0037
21.1457 20.0392
13.3596 21.5270
13.3596 21.5270
13.3596 20.0392
NaN 17.0037
NaN 16.1477
NaN 16.1477
NaN 16.1477]
Y_data =
[ 0 0
1.8725 1.8725
16.9650 4.9160
16.9650 13.2470
1.8725 16.9662
0 16.9662
0 13.2470
NaN 4.9160
NaN 1.8725
NaN 0
NaN 0]
Z_data =
[ -0.8831 -1.0298
-0.8831 -1.0298
-0.1197 -0.9071
-0.3400 -0.3906
-1.6715 -0.1558
-1.6715 -0.3172
-0.8831 -0.6376
NaN -1.3943
NaN -1.7909
NaN -1.7909
NaN -1.0298];
The figure I want should have two surfaces, defined by each column from the data. The presence of NaN make matlab only draws the outline for the surface; the second surface is ok. I used:
fill3(X_data,Y_data,Z_data,'r')
Any suggestions? Thank you!
  3 个评论
Gang-Gyoo
Gang-Gyoo 2012-11-4
How about using these codes
fill3(X_data(1:7,1),Y_data(1:7,1),Z_data(1:7,1),'r')
hold on
fill3(X_data(:,2),Y_data(:,2),Z_data(:,2),'r')
hold off
grid on
Pengfei
Pengfei 2012-11-6
Hi, Thanks! That actually helps. I didn't realize the small trick!

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation of 2-D Selections in 3-D Grids 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by