Working with a sturcture, rename top layer by a cell array

1 回表示 (過去 30 日間)
MeLearningProgramming
MeLearningProgramming 2019 年 8 月 1 日
編集済み: Joel Handy 2019 年 8 月 5 日
Dear comunity,
i'm really struggling by reaming the top layer of a stucture.
so i have a structure s
s = 1×3 struct array with fields: f1 f2 ....f12 (each field contains a datetime and a double vector)
s(1:3).field(1:12).time
s(1:3).field(1:12).data
well i do not have a problem with renaming the field part, its easy by just using dynamic variables:
newname = {'something1', 'something2', 'something3'}; j = 1;
s.(newname{j}).data gives me s.something1.data
BUT my problem starts, when i want to rename the top layer of the sturcture:
desired output would be: something1.field.time/ something1.field.data
newname{j} = s(1)
newname = 1×3 cell array with {1×1 struct} {'something2'} {'something3'}
well herby the sturcture changes just to newname{1, 1}
any hints to do better?
regards, MLP
  9 件のコメント
MeLearningProgramming
MeLearningProgramming 2019 年 8 月 5 日
編集済み: MeLearningProgramming 2019 年 8 月 5 日
hihihi ... thanks guys.
s ist the varagout of my import funktion. Now I wanted to prepare parts of the sturcture s as an input and other parts of the structure s as output for the fitnet/narxnet.
InputVektor = [AWH.field.data, GOE.field.data];
TargetVektor = [VTB.field.data];
regards
Joel Handy
Joel Handy 2019 年 8 月 5 日
編集済み: Joel Handy 2019 年 8 月 5 日
The question is why do you want to make structure 's' a 3x1 struck array in the first place if what you really want is three independant structures.
You mentioned s is the ouput of an import function. If this function is generic and you want to break the data out differently after its been imported, simply assign the data in s to new variables.
AWH = s(1);
VTB = s(2);
GOE = s(3);

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by