MATLAB Answers

Assigning Cell Arrays to Nested Structures within Structure array with Same Dimensions (Error: "Scalar structure required for this assignment")

34 ビュー (過去 30 日間)
Soma Mizobuchi
Soma Mizobuchi 2019 年 8 月 26 日
Commented: xi 2019 年 8 月 26 日
I currently have a structure containing a 2x1 structure array each containing a structure with one field:
I have tried to assing values from a cellfun to 'field1_1' using the following code:
[struct.structArr.field1.field1_1] = outputOfCefllfun{:};
The 'structArr' is a 2x1 matrix of structures and the output of the cellfun is a 2x1 cell array each containing a matrix of doubles.
I receive the following error:
Scalar structure required for this assignment.
Is there any way of assigning these values without having to do another cellfun?
Any help would be appreciated, thank you.

  0 件のコメント

サインイン to comment.

件の回答 (1)

xi 2019 年 8 月 26 日
I don't know how your struct is initialized. It should work.
[struct.structArr.field1] = outputOfCefllfun{:};

  2 件のコメント

Soma Mizobuchi
Soma Mizobuchi 2019 年 8 月 26 日
Hey Xi,
Thanks for the reply. I've revised my question to fit the exact problem I was having. I am actually looking to assign the output values from the cellfun to a field in a further nested structure within each structure of the structArr. Sorry for the confusion. Any help is appreciated, thanks.
xi 2019 年 8 月 26 日
Further nested structure is getting more complicated, but you can always use "for loop" to assign the values.
for i=1:2

サインイン to comment.

サインイン してこの質問に回答します。




Translated by