Fill polygon with NaN data

1 Ansicht (letzte 30 Tage)
Pengfei
Pengfei am 3 Nov. 2012
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 Kommentare
Gang-Gyoo
Gang-Gyoo am 4 Nov. 2012
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 am 6 Nov. 2012
Hi, Thanks! That actually helps. I didn't realize the small trick!

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Interpolation of 2-D Selections in 3-D Grids finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by