optimize my matrix function

7 ビュー (過去 30 日間)
danielle sisserman
danielle sisserman 2020 年 11 月 7 日
コメント済み: danielle sisserman 2020 年 11 月 7 日
this is my code:
t=1;
for j=k_indices
knn_labels(t,1) = classifier.Ytrain(j,1);
t = t+1;
end
what I'm doing here is using a vector of indices to create a vector of the values at those indices using some other matrix:
example:
But, I am sure that there is some pretty one liner that does this. Any one knows what that line looks like?
Thank you

採用された回答

Walter Roberson
Walter Roberson 2020 年 11 月 7 日
knn_labels = reshape( classifier.YTrain(k_indices), [], 1);
  1 件のコメント
danielle sisserman
danielle sisserman 2020 年 11 月 7 日
perfect! thank you Walter :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProblem-Based Optimization Setup についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by