MATLAB: Reshaping a Structure using structfun command and reshape

reshapestructfun

Hi:
I want to apply the command function structfun to a structure which has 16 fields each of size (5 rows and 10 columns)
Assume one of the fields is:
A= rand(5,10)
B=reshape(A,50,1)
I want to do this for every field (Matrix) in this structure.
Best regards

Best Answer

structfun(@(fld) reshape(fld, 50, 1), yourstruct)
or
structun(@(fld) fld(:), yourstruct)
Related Question