フィルターのクリア

How to extract the max items in struct?

2 ビュー (過去 30 日間)
sana3 sal
sana3 sal 2018 年 8 月 2 日
コメント済み: sana3 sal 2018 年 9 月 5 日
Hello there, I have a struct of faces and vertices, how to extract the item that has the maximum faces and vertices?
  2 件のコメント
Rik
Rik 2018 年 8 月 2 日
What do you mean with maximum?
sana3 sal
sana3 sal 2018 年 8 月 2 日
for example, here the max faces and vertices are field number 1

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

採用された回答

OCDER
OCDER 2018 年 8 月 2 日
編集済み: OCDER 2018 年 8 月 2 日
When you say "max", did you mean "max number of elements" or "max value within a vector"? Did you want something like this?
for j = 1:10 %Just creating a test case structure
A(j,1) = struct('faces', zeros(1, randi(1000)), ...
'vertices', zeros(1, randi(1000)));
end
Faces = cellfun('length', {A.faces});
Vertices = cellfun('length', {A.vertices});
MaxIdx = find(Faces == max(Faces) & Vertices == max(Vertices));
  2 件のコメント
Rik
Rik 2018 年 8 月 2 日
The output may be empty or nonscalar.
sana3 sal
sana3 sal 2018 年 9 月 5 日
Thank you very much you saved my life ♥

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by