DimensionMismatch (“A has dimensions (1, 0) but B has dimensions (5,)”)

How to eliminate this error?

# DimensionMismatch ("A has dimensions (1, 0) but B has dimensions (5,)") How to eliminate this error?

You’re more likely to get useful feedback if you can provide a small copy and pasteable example that demonstrates the problem. Also be sure to quote your code when you do so.

```
# it will look better when you start your code example with ```julia
for i=1: size(TabelaRecursos, 1)
TipoRecursos = newTabelaRecursos[i]
Dr = newTabelaRecursos[i,2]
k =0
Aux = Array{Any}(0)
for j = 1: size(newTabelaProdutos_Recursos, 1)
if newTabelaProdutos_Recursos[j, 2] == TipoRecursos
k = k +1
insert!(Aux, k, newTabelaProdutos_Recursos[j, 3])
end
end
Drp = transpose(Aux)
@constraint(myModel, Drp*Qp <= Dr) # the following error appears on this line:
DimensionMismatch(“A has dimensions (1, 0) but B has dimensions (5,)”)
end
# and end it with ```
```

This is what I am getting when I copy and paste your code:

```
julia> using JuMP
julia> for i=1:size(TabelaRecursos, 1)
TipoRecursos = newTabelaRecursos[i]
Dr = newTabelaRecursos[i,2]
k =0
Aux = Array{Any}(0)
for j = 1: size(newTabelaProdutos_Recursos, 1)
if newTabelaProdutos_Recursos[j, 2] == TipoRecursos
k = k +1
insert!(Aux, k, newTabelaProdutos_Recursos[j, 3])
end
end
Drp = transpose(Aux)
@constraint(myModel, Drp*Qp <= Dr) # the following error appears on this line:
end
ERROR: syntax: unexpected "="
```

You probably mean `<=`

in place of `<=`

. Even after fixing that, the variables are not defined so I cannot properly debug the code. So it is not that people don’t want to help, it’s just that you have to start by helping them help you.

As mentioned before, it would be really helpful if you could preface wrap code blocks with `````

to turn them into properly formatted code.

Also, I’m assuming it’ll still be hard for people to help given that your code depends on data read in locally on your machine, and therefore is not the minimal, complete, and verifiable example necessary to actually reproduce and debug your problem.

That said it looks likely that your error comes from a multiplication of to incompatible matrices, so you should probably go through your code step by step to try and understand why the dimensions of `A`

and `B`

are what they are and what dimensions they should have for your calculations to work.

Ok, thank you.