why computeCost function shows incorrect dimension error in second call?
Mostrar comentarios más antiguos
h = X * theta;
sq_error = (h - y) .^ 2;
J = 1/(2*m) * sum(sq_error);
correcting the code with error message shows error in first call too.

Respuestas (1)
Hritika Suneja
el 31 de Dic. de 2020
Editada: Hritika Suneja
el 4 de En. de 2021
0 votos
As the error suggests , the dimensions of the matrix being multiplied might not be consistent. In order to multiply 2 matrix the number of columns in the first matrix should match the number of rows in the second matrix. This condition might not be getting satisfied in your code and hence this error occurs.
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!