how can I create a new structure based on a existing one?

조회 수: 5 (최근 30일)
Skirt Zhang
Skirt Zhang 2013년 2월 8일
Dear All,
I have a structure A as below
A
a1[1*1]
a21[1*1] a22[1*1]
a31[1*1] a32[1*1] a33[1*1] a34[1*1]
I want to get a new A as following
A new
a1[1*1] same as before
a21[1*1] a21[1*1] a22[1*1] a22[1*1]
a31[1*1] a31[1*1] a32[1*1] a32[1*1] a33[1*1] a33[1*1] a34[1*1] a34[1*1]
eg a21 is just refering the element in the structure and 1*1 is the dimension for each element, here it is a number.
For further usage I have to store it in this structure. Thanks a lot in advance
  댓글 수: 3
Jan
Jan 2013년 2월 8일
Please use valid Matlab syntax to describe your data. It is inefficient if we have to guess the details. Thanks.
Skirt Zhang
Skirt Zhang 2013년 2월 8일
편집: Skirt Zhang 2013년 2월 8일
A is a matrix like structure a1[1*1] is the first and the only element on line one a21[1*1] a22[1*1] are the only two elements on the 2nd line and so on
a1 is as below (like a tree branch)
* -->0.1
1
* -->0.9
1 is stored in A{1}.parent o.1 is stored in A{1}.childdown o.9 is stored in A{1}.childup

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

답변 (1개)

Thorsten
Thorsten 2013년 2월 8일
If you want to build a structure A of class struct (such that >> class(A) yields 'ans = struct') you cannot do it because the fields of the struct a1, a22 etc have to have different names. Or is your 'structure A' a matrix?

카테고리

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