I have (for example) this struct array in MATLAB
g=struct();
g.var1=[0,1,2];
g.var2=[5,6,7];
g.var3={'a','b','c'};
...
I want to create a cell array that samples (meshgrids) all fields one by one
Wanted a cell array;
M×N cell array
{[0]} {[5]} {'a'}
{[0]} {[5]} {'b'}
{[0]} {[5]} {'c'}
{[1]} {[5]} {'a'}
{[1]} {[5]} {'b'}
{[1]} {[5]} {'c'}
{[2]} {[5]} {'a'}
{[2]} {[5]} {'b'}
{[2]} {[5]} {'c'}
{[0]} {[6]} {'a'}
{[0]} {[6]} {'b'}
{[0]} {[6]} {'c'}
{[1]} {[6]} {'a'}
{[1]} {[6]} {'b'}
{[1]} {[6]} {'c'}
...
...
I want my code to work for all general cases, such as an input struct with only 1 field or many fields.
What is a clever way of coding this?