How to extract the max items in struct?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello there, I have a struct of faces and vertices, how to extract the item that has the maximum faces and vertices?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/193032/image.jpeg)
2 commentaires
Réponse acceptée
OCDER
le 2 Août 2018
Modifié(e) : OCDER
le 2 Août 2018
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graphics Performance dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!