MATLAB: Removing element from structure.

structure array

I want to remove a element from a 1×8 struct. Simply doing it equal to empty brackets its not enough. I want it to became 1×7 struct.

Best Answer

Why is it not enough? Can't you do
% Create a structure array:
for k = 1 : 8
myStruct(k).f1 = k;
myStruct(k).f2 = 2 * k;
end
% Delete the 5th structure from the array.
myStruct(5) = [];
Works beautifully for me.