MATLAB: Transpose a structure with named fields

MATLABstructtabletranspose

I have a struct that looks like this:
i.g. labeled fields
I have been trying to apply this example:
% Fake data
s(1).f = rand(1,100);
s(2).f = rand(1,100);
s(3).f = rand(1,100);
c = arrayfun(@(x)x.f.', s, 'UniformOutput', 0);
s = cell2struct(c, 'f');
but I think it doesn't work becuase I have labeled feilds.
Any ideas?

Best Answer

if all of them are scalar then this will work
s_mod=structfun(@transpose,s,'UniformOutput',false)