필터 지우기
필터 지우기

extract field from a structure problem

조회 수: 2 (최근 30일)
Yu Li
Yu Li 2018년 11월 15일
편집: Stephen23 2018년 11월 15일
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
Stephen23
Stephen23 2018년 11월 15일
편집: Stephen23 2018년 11월 15일
@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?

댓글을 달려면 로그인하십시오.

채택된 답변

Bruno Luong
Bruno Luong 2018년 11월 15일
depending on the content, if scalar
tmp=[DP1.P]
or if not
tmp={DP1.P}
  댓글 수: 1
Yu Li
Yu Li 2018년 11월 15일
Thank you, your answer works.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by