필터 지우기
필터 지우기

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 CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by