Please post the relevant part of the code. It is not possible to guess, if "embed" is a matrix or a function. E.g. "message" could be shorter than "imdexm+1" etc.
A recommended method to solve such problems is the debugger:
dbstop if error
Then MATLAB stops, if the error occurs and you can inspect the values of the variables to find the cause of the problem. This is more efficient than asking the forum.