Array dimensions must match for binary array op

4 visualizaciones (últimos 30 días)
Ricardo Olvera
Ricardo Olvera el 30 de Mzo. de 2017
Comentada: Saiful Haqiqi Hassan el 17 de Dic. de 2018
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?

Respuesta aceptada

Walter Roberson
Walter Roberson el 30 de Mzo. de 2017
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 comentarios
Ricardo Olvera
Ricardo Olvera el 30 de Mzo. de 2017
Thank you so much :) that was the problem, and I already solved it.
Saiful Haqiqi Hassan
Saiful Haqiqi Hassan el 17 de Dic. de 2018
I am using r2018a. and still encountered this problem.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by