for i=1:m
for j=2:11
mse=1/m(sum(w_opt(1)+w_opt(j)*X_train(i,j)-y_train(i))^2);
end
end
Array indices must be positive integers or logical values.

1 Commento

Hp2609
Hp2609 il 9 Mar 2021
w_opt is (11,1) vector, X_train is (333,11) matrix and y_train is (333,1) vector

Accedi per commentare.

 Risposta accettata

Jan
Jan il 9 Mar 2021
Modificato: Jan il 9 Mar 2021
This appears in your code:
mse=1/m(sum(w_opt(1)+w_opt(j)*X_train(i,j)-y_train(i))^2);
% ^^^^^
This treats m as a variable and sum(w_opt(1)+w_opt(j)*X_train(i,j)-y_train(i))^2 as index.
Maybe you mean:
mse = 1 / m * (sum(w_opt(1) + w_opt(j) * X_train(i,j) - y_train(i))^2);

Più risposte (0)

Tag

Richiesto:

il 9 Mar 2021

Commentato:

il 9 Mar 2021

Community Treasure Hunt

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

Start Hunting!

Translated by