Calculate argmin for the function in matlab
조회 수: 40 (최근 30일)
이전 댓글 표시
I want to find the value of the following using matlab:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/854420/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/854425/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/854430/image.png)
댓글 수: 0
채택된 답변
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]))
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]
[~,minind] = min((a' - S).^2,[],2);
V = S(minind)
sum(V)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!