Error Unable to perform assignment because dot indexing is not supported for variables of this type.

1 次查看(过去 30 天)
Simple code
TestStruct.Level1A='TestStruct_Level1A';
TestStruct.Level1B='TestStruct_Level1B';
TestStruct.Level1B.Level2='TestStruct_Level1B_Level2';
gives error
Unable to perform assignment because dot indexing is not supported for variables of this type.
Error in Sample1 (line 3)
TestStruct.Level1B.Level2='TestStruct_Level1B_Level2';
Why does this work at the first level but not the second? How can I make it work?

采纳的回答

Bob Thompson
Bob Thompson 2019-10-30
You are receiving the error because you have already defined the class of the first level as a character. In order to add a second level to it you would have to define it as a structure.
>> TestStruct.Level1B='TestStruct_Level1B';
>> class(TestStruct.Level1B)
ans =
'char'
>>

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by