# DimensionMismatch("arrays could not be broadcast to a common size; )

**URL:** https://discourse.julialang.org/t/dimensionmismatch-arrays-could-not-be-broadcast-to-a-common-size/72448
**Category:** General Usage
**Created:** [December 2, 2021, 11:30am UTC](https://discourse.julialang.org/t/dimensionmismatch-arrays-could-not-be-broadcast-to-a-common-size/72448 "2021-12-02T11:30:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![FH96](https://avatars.discourse-cdn.com/v4/letter/f/4da419/32.png) [@FH96](https://discourse.julialang.org/u/FH96)
#### Post date: [December 2, 2021, 11:30am UTC](https://discourse.julialang.org/t/dimensionmismatch-arrays-could-not-be-broadcast-to-a-common-size/72448/1 "2021-12-02T11:30:20Z")

</div>

I’m trying to write a simple for loop!:  
`for coef in reacions_to_test`  
in which “reacions\_to\_test” is `2582-element Vector{Int64}`

but I face this error :

`DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths 2583 and 2")`

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [December 2, 2021, 11:56am UTC](https://discourse.julialang.org/t/dimensionmismatch-arrays-could-not-be-broadcast-to-a-common-size/72448/2 "2021-12-02T11:56:17Z")

</div>

I don’t think it’s possible to give meaningful help without an MWE that reproduces this. The error is relatively clear I think:

```julia
julia> rand(5) .* rand(7)
ERROR: DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths 5 and 7")

```

but how you manage to get it is impossible to tell without an MWE and a stack trace that gives a line number.

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [December 2, 2021, 12:46pm UTC](https://discourse.julialang.org/t/dimensionmismatch-arrays-could-not-be-broadcast-to-a-common-size/72448/3 "2021-12-02T12:46:47Z")

</div>

If `reacions_to_test` is the source of the problem (there is a slightly discrepancy because it has length 2582 but the error message says 2583). Then you are trying to broadcast some operation over it and a two-element container, the other container should either have length 1 or the same size as `reacions_to_test`.
