フィルターのクリア

How to fill a 3D plot?

43 ビュー (過去 30 日間)
Stephan
Stephan 2016 年 12 月 18 日
コメント済み: Vikash Chaurasia 2022 年 3 月 7 日
Hello everyone,
I have the following code showing a square. What I have to do to get it filled?
Many thanks!
figure
X = [0,0,1,1; 1,0,1,1; 1,0,1,1; 1,0,1,0];
Y = [0,0,0,1; 0,1,1,1; 0,1,1,1; 0,1,1,1];
Z = [1,1,1,1; 1,1,1,1; 1,1,1,1; 1,1,1,1];
C=[1,1,1,1;1,1,1,1;1,1,1,1;1,1,1,1];
fill3(X,Y,Z,C);

採用された回答

John BG
John BG 2016 年 12 月 19 日
編集済み: John BG 2016 年 12 月 19 日
Stephan
1st
your code is confusing because your are not defining 1 square, you are defining 4 squares
2nd
it is already filled, let me explain:
when you generate a surface with commands like fill3 patch surf surface
all you have to do is to collect the handle, for instance
h1=fill3(X,Y,Z,C)
4x1 Patch array:
Patch
Patch
Patch
Patch
as you can see, with your current X Y Z you have 4 overlapped patches.
When attempting to change parameters like transparency and face colour, it can get confusing, so let's simplify
X = [0,1,1,0];
Y = [0,0,1,1];
Z = [1,1,1,1];
h2=fill3(X,Y,Z,[0 0 1])
note that the order of introduction of points matters, if you jump to an opposite vertex the square will look like a bow tie.
To change color and transparency all you have to write in example:
h2.FaceColor=[1 0 0]
h2.FaceAlpha=0.3
if you find these lines useful would you please mark my answer as Accepted Answer?
To any other reader, please if you find this answer of any help, click on the thumbs-up vote link,
thanks in advance for time and attention
John BG
  3 件のコメント
Vikash Chaurasia
Vikash Chaurasia 2022 年 3 月 7 日
Excellent solution. Many thanks!
Vikash Chaurasia
Vikash Chaurasia 2022 年 3 月 7 日
Could you please tell how to extract mesh data from the handle h1=fill3(X,Y,Z,C) and export it in the text file ? I need the coordinates of the points on the surface created by fill3 command. Thank you very much!

サインインしてコメントする。

その他の回答 (1 件)

michio
michio 2016 年 12 月 19 日
編集済み: michio 2016 年 12 月 19 日
I am not sure what you want but if you simply want to create a filled square
X = [0; 1; 1; 0];
Y = [0; 0; 1; 1];
Z = [1; 1; 1; 1];
C=[0; 0.25; 0.50; 0.75];
C needs to be a vector or matrix of indices into the current colormap.

カテゴリ

Help Center および File ExchangePolygons についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by