need struct2array because Matlab is too old
adding alexs code