remove a struct field that its element value is less than specific 50
Ältere Kommentare anzeigen
Hi, I have 4x1 struct with 2 fields as shown:

i want to delete the one that has less faces and vertices for example here field number 4 i have tried this:
Faces = cellfun('length', {CClower.faces});
Vertices = cellfun('length', {CClower.vertices});
MinIdx = find(Faces <= 50);
but now how to select indexes that not equal to MinIdx that i extracted?
3 Kommentare
"remove a struct field that its element value is less than specific 50"
This is not clear: it seems that you actually want to remove the fourth element of the structure, not any field of the structure. Is the expected output a 3x1 structure with two fields?
sana3 sal
am 4 Okt. 2018
Stephen23
am 4 Okt. 2018
"i need to remove the element that is smaller than 50 whatever is its location."
That is what my answer does.
Antworten (1)
If you want to remove elements of the structure use logical indexing:
Faces = cellfun('length', {CClower.faces});
CClower(Faces<50) = []
Kategorien
Mehr zu Structures finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!