why computeCost function shows incorrect dimension error in second call?

조회 수: 1 (최근 30일)
Tshering Lhamo
Tshering Lhamo 2020년 9월 8일
편집: Hritika Suneja 2021년 1월 4일
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.

답변 (1개)

Hritika Suneja
Hritika Suneja 2020년 12월 31일
편집: Hritika Suneja 2021년 1월 4일
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.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by