Array dimensions must match for binary array op

4 次查看(过去 30 天)
Hello, I got a problem with this error: "Array dimensions must match for binary array op", the problem is that I used to use the trial version of matlab and my code works, but now I use the licensed version and it throw me a lot of errors like that when It used not to do it. Can someone explain this?

采纳的回答

Walter Roberson
Walter Roberson 2017-3-30
The trial version would have been R2017a probably. But the licensed version might have been R2016a or earlier.
One of the changes in R2016b was to automatically do the equivalent of bsxfun in some cases. For example if you had
A = (1:5)';
B = [10 20 30];
then in versions up to R2016a, A+B would be an error because arrays of size 5 x 1 could not be added to arrays of size 1 x 3. But as of R2016b, the situation would be treated as being like
bsxfun(@plus, A, B)
automatically replicating data to produce the answer
11 21 31
12 22 32
13 23 33
14 24 34
15 25 35
Your code accidentally used this feature and did something in the trial version, but then you moved over to an earlier version without the feature and the code failed.
For example your code might have X + Y but X might be a row vector and Y might be a column vector of the same length. In earlier versions that would be an error; from R2016b onwards it has been defined to do something. It might not be what you want done, but it does something.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by