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 Comment

w_opt is (11,1) vector, X_train is (333,11) matrix and y_train is (333,1) vector

Sign in to comment.

 Accepted Answer

Jan
Jan on 9 Mar 2021
Edited: Jan on 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);

More Answers (0)

Tags

Asked:

on 9 Mar 2021

Commented:

on 9 Mar 2021

Community Treasure Hunt

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

Start Hunting!