"patch" command error

22 ビュー (過去 30 日間)
kai
kai 2019 年 5 月 17 日
コメント済み: Rik 2019 年 5 月 18 日
mac -OS
MATLAB version-2018a
I have two matrices one with vertices-(280×3) and the other one with faces-(556×3) .
Using patch command as follows
P=patch('Faces',f11,'Vertices',k1); %%%%%f11= face matrix and k1=vertex matrix.
set(P,'FaceColor','b','FaceAlpha',0.5);
set(P,'EdgeColor','k','LineWidth',2);
It gives the following error
Error using patch
Value must be of numeric type and greater than 1
Attached are the two files containing the matrices.
Any suggestions on how to eliminate this problem
Thanks.

採用された回答

Rik
Rik 2019 年 5 月 17 日
I suspect you generated the vertex IDs in a programming language that is zero-indexed, instead of one-indexed. If that is the case you can probably fix the issue like this:
P=patch('Faces',1+f11,'Vertices',k1); %%%%%f11= face matrix and k1=vertex matrix.
set(P,'FaceColor','b','FaceAlpha',0.5);
set(P,'EdgeColor','k','LineWidth',2);
  2 件のコメント
kai
kai 2019 年 5 月 18 日
Thank you Rik for the answer, now it works fine.
Just curious.. How did you came to a conclusion that vertex IDs generated are zero indexed.
Rik
Rik 2019 年 5 月 18 日
You're welcome.
I assumed they weren't generated by Matlab, and most other programming languages are zero indexed. So it was an educated guess. And generally the first few faces will contain the first vertex, but in the txt there were a few zeros where I expected ones.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by