How to find the maximum length in a structure of vectors?
33 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a struct, fem. One of its field is a cell (fem.Element) and I want to find the maximum length of fem.Element.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/169504/image.png)
Thanks in advance, André
0 Commenti
Risposta accettata
Più risposte (1)
Precise Simulation
il 12 Nov 2017
If by "maximum length" you mean the number of struct entries, then you can just use one of the standard length, numel, or size commands
length(fem)
numel(fem)
size(fem)
If you mean the maximum value in each struct entry you could use something like
mx_all = cellfun(@max,struct2cell(fem))
mx = max(mx_all(:))
2 Commenti
Vedere anche
Categorie
Scopri di più su Structures in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!