Array dimensions must match for binary array op

조회 수: 5 (최근 30일)
Ricardo Olvera
Ricardo Olvera 2017년 3월 30일
댓글: Saiful Haqiqi Hassan 2018년 12월 17일
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.
  댓글 수: 2
Ricardo Olvera
Ricardo Olvera 2017년 3월 30일
Thank you so much :) that was the problem, and I already solved it.
Saiful Haqiqi Hassan
Saiful Haqiqi Hassan 2018년 12월 17일
I am using r2018a. and still encountered this problem.

댓글을 달려면 로그인하십시오.

추가 답변 (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