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 件のコメント

Hp2609
Hp2609 2021 年 3 月 9 日
w_opt is (11,1) vector, X_train is (333,11) matrix and y_train is (333,1) vector

サインインしてコメントする。

 採用された回答

Jan
Jan 2021 年 3 月 9 日
編集済み: Jan 2021 年 3 月 9 日

0 投票

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

1 件のコメント

Hp2609
Hp2609 2021 年 3 月 9 日
got it thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索

タグ

質問済み:

2021 年 3 月 9 日

コメント済み:

2021 年 3 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by