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 commentaire

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

Connectez-vous pour commenter.

 Réponse acceptée

Jan
Jan le 9 Mar 2021
Modifié(e) : Jan le 9 Mar 2021

0 votes

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);

Plus de réponses (0)

Catégories

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by