The error message tells us the error occurs on this line:
Rx=(XX)-Loc([]);
Those variables are hardcoded as:
Loc=[];
XX=(2,-2);
Presumably you have not copied your code correctly, because that XX definition is not valid MATLAB code, and will immediately cause an error:
>> XX=(2,-2);
??? XX=(2,-2);
|
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
Once we fix that by replacing the parentheses by square brackets we can try that code out. The code Loc([]) takes no elements of an empty vector, giving an empty vector. So your code is equivalent to this:
>> [2,2] - []
??? Error using ==> minus
Matrix dimensions must agree.
What output do you expect to get when you subtract an empty vector from a 1x2 vector?
When doing matrix arithmetic either:
- one array can be scalar, or
- both arrays must be the same size.
