Structure fields in Matlab

조회 수: 5 (최근 30일)
Diana Acreala
Diana Acreala 2012년 7월 27일
Hello!
I have a structure that can contain several substructures, and sub-sub-structures and so on. I will never know for sure how deep is my structure.
But I'll know for sure that each substructure of my structure will contain the field "SignalName" and this is exactly what I need.
Is there a command for getting what I need? I tried to create an algorithm but looks impossible because I never know how much to dig into the structure...
Until now I have not found any command to help me..
Thanks! Bye
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 7월 28일
You do not appear to have explained what it is you need ? You have nested structures of unknown depth and you need to do something with the fields named SignalName, but you did not indicate what you want to do with those fields.

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

답변 (2개)

Sean de Wolski
Sean de Wolski 2012년 7월 27일
편집: Sean de Wolski 2012년 7월 27일
It sounds like you will want to use fieldnames to get a cell array of the fields. You could then use ismember with 'SignalName' and field names to find out if it is a member. If it is, dynamically call it using dynamic field names. If it is not, recursively continue.
My question to you:
Why do you receive structures whose structure you don't know a priori? I would invest more time in trying to organize these.

Azzi Abdelmalek
Azzi Abdelmalek 2012년 7월 28일
편집: Azzi Abdelmalek 2012년 8월 26일

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by