- What are you tring to do?
- What is the value of M?
- What is Datfit and sumfitness?
- Can you post the error?
Error using / matrix dimensions must agree
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
for i=1:M
Prob(i) = Datfit(i)/sumfitness;
end
halo. here's my code. i want to know the solution bcs there's always error
1 comentario
Sebastiano Marinelli
el 10 de Jun. de 2021
May ask you more information:
anyway if the problem is the one on the titile it may due to an error on the division, maybe sumfitness has a different dimension than the Datafit, but we need more info :)
Respuestas (1)
Walter Roberson
el 10 de Jun. de 2021
We can tell from the error that sumfitness is not a scalar, and so the / operator is the matrix right division operator, which would be similar in effect to Datfit(i) * pinv(sumfitness) if the operation were permitted.
The / operator requests to solve simultaneous linear equations for best fit, but that requires compatible sizes on the left and right size of the equations.
We might suspect that you want element-by-element division, which would be Datfit(i) ./ sumfitness . However we can tell from the error that if you were to change that then the result you got from the right hand side would be a vector and the vector would not fit into the output location.
So... either you have to fix sumfitness to be a scalar instead of a vector, or else we have to guess that you might mean something like
Prob(i) = Datfit(i) ./ sumfitness(i);
0 comentarios
Ver también
Categorías
Más información sobre MATLAB Coder en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!