Calculate argmin for the function in matlab

71 ビュー (過去 30 日間)
Yokuna
Yokuna 2022 年 1 月 5 日
編集済み: John D'Errico 2022 年 1 月 5 日
I want to find the value of the following using matlab:
where . S is the set of the numbers as given. .

採用された回答

John D'Errico
John D'Errico 2022 年 1 月 5 日
編集済み: John D'Errico 2022 年 1 月 5 日
What have you tried? Why not? And why did you feel you needed a picture of the vector S? That just makes us type it in. Not gonna happen. Just because you want fancy formatting makes it more difficult for you to get help?
S = sort(randi(100,[1,10]))
S = 1×10
5 19 19 37 54 60 61 65 75 76
Next, learn to use VECTORS. Don't number your variables. Silly, becuase we know you have been using MATLAB for a while.
It looks like you want to find the closest elements in S to each of the members of a. Then form the sum.
a = [10:20:100]
a = 1×5
10 30 50 70 90
[~,minind] = min((a' - S).^2,[],2);
V = S(minind)
V = 1×5
5 37 54 65 76
sum(V)
ans = 237

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by