Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

??? Subscripted assignment between dissimilar structures.

Asked by AP on 11 Jun 2011
Latest activity Commented on by Matt J on 24 Nov 2014

I am using a structure in my script m-file. Everytime I run my code, I get the following error:

??? Subscripted assignment between dissimilar structures.

To run the code, I clear all the variables and then re-run the code. This way I don't get the error. Is there something that I am missing?





No products are associated with this question.

3 Answers

Answer by Jan Simon on 12 Jun 2011
Accepted answer

The error message contains the line number also. Inspect this line to find out, why the structs are different.

Another method for debugging is using the debugger (sic!):

dbstop if error

1 Comment

AP on 12 Jun 2011

Thank you Jan. This is a really cool.

Jan Simon
Answer by Matt Fig on 12 Jun 2011

It sounds like you are running a script instead of a function? If so, my guess is that with a clear workspace your code creates some variables, but these creation assignments don't work right when the variables are built up by the code if run again without a clear workspace. This is the best I can do without seeing the code...

1 Comment

AP on 12 Jun 2011

Thank you. The error was because of the following:
in the definition of the structure I had defined MaterialSize whereas in my code I had used Materialsize where the letter 's' is not capitalized as in the definition.

Matt Fig
Answer by Marine on 24 Nov 2014

I have actually the same mistake as AP, but the point is that when I test me structures, they are supposed to be the same in the program, and I really don't know why I got this message. One of my structure comes from a .mat-file, and the other is describe in my script... Can anybody help me please ?

1 Comment

Matt J on 24 Nov 2014

What about Jan's answer, recommending dbstop? What does that reveal?


Contact us