MATLAB: Clear all fields of a struct

clearMATLABstruct

Hi,
I have a struct with a number of fields that I want populate, and then store, each iteration through a loop. I want the struct to be empty and available each iteration. Is there a function to clear all the fields? Or do I just declare the whole thing again?
I tried setting each feild individually to [], like
myStruct.a = [];
myStruct.b = [];
But it's actually faster to declare the whole thing new each iteration, as in:
myStruct = struct('a', [], 'b', []);
Or maybe there's a better approach all together?
Cheers, Karl

Best Answer

A colleague suggested this:
myStruct = structfun(@(x) [], myStruct, 'UniformOutput', false);
It's about the same speed-wise, maybe a little faster on average. But it's nice and neat :)