MATLAB Answers

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

5 views (last 30 days)
Jay Land
Jay Land on 30 Oct 2019
Answered: Bob Nbob on 30 Oct 2019
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?

  0 Comments

Sign in to comment.

Accepted Answer

Bob Nbob
Bob Nbob on 30 Oct 2019
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 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.