Delete rows in struct based on number of elements in field
6 views (last 30 days)
I have a 1x68 struct with 7 fields - Scouts. I want to delete rows where the number of elements under a field 'Vertices' is less than 20. How do I do this? I tried;
Scouts.Vertices(numel(Scouts.Vertices<20)) = 
but got Error using < Too many input arguments.
I would prefer not to run a loop.
Also tried this but comes back as rows = 
[rows,~] = find(numel(Scouts.Vertices)>10);
Rik on 22 Aug 2022
If you mean you want to remove elements from your struct, you're fairly close already. Scouts.Vertices returns a comma separated list. You need to feed that to a function that will capture the output.
You could do this:
ind = find(tmp>10);
But using a loop would be much simpler.
You could also use structfun, but that would only hide the loop and increase complexity as well.