Filter löschen
Filter löschen

extract field from a structure problem

2 Ansichten (letzte 30 Tage)
Yu Li
Yu Li am 15 Nov. 2018
Bearbeitet: Stephen23 am 15 Nov. 2018
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
  1 Kommentar
Stephen23
Stephen23 am 15 Nov. 2018
Bearbeitet: Stephen23 am 15 Nov. 2018
@Yu Li: your code is like this:
tmp = DP1(:).P
whereas the code in the thread you linked to is like this:
tmp = [DP1(:).P]
Do you notice the difference?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Bruno Luong
Bruno Luong am 15 Nov. 2018
depending on the content, if scalar
tmp=[DP1.P]
or if not
tmp={DP1.P}

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by