MATLAB: Extract field from a structure problem

extract value from structure

Hi:
I need to extract the field 'P' from a structure, to form a new structure with all the value of P. but I the answer in link below:
does not work, it only keeps the last one of the structure.
my command is tmp=DP1(:).P
Thanks!
Yu

Best Answer

depending on the content, if scalar
tmp=[DP1.P]
or if not
tmp={DP1.P}