MATLAB: How to delete elements from structure

delete from structureMATLAB

I have a structure of the above kind.
Lets choose , cell.population(1).type = 1
cell.population(2).type = 2
cell.population(1).profile = [1 1 2]
cell.population(2).profile = [2 1 2]
Now if I use use " cell.population(1).profile = [ ] " and " cell.population(1).type = [ ] " to delete the profile and type, then it doesn't get deleted. It remains as a blank vector ( [ ] ) in memory.
What should I do?

Best Answer

Deleting an element of a structure is easy, and it has nothing to do with fields:
S.population(1).type = 1;
S.population(2).type = 2;
S.population(1).profile = [1 1 2];
S.population(2).profile = [2 1 2];
S.population(1) = [] % delete the first element of S.population