maximization of a function of 2 variables
조회 수: 1 (최근 30일)
이전 댓글 표시
I have two arrays ,
avgDistance and energy
I need to find out the array position with minimum avgDistance and maximum energy.
help me.....
댓글 수: 1
Anathea Pepperl
2011년 3월 25일
I'm not sure I understand. Could you clarify if you mean that, given the minimum avgDistance, you need to find the maximum energy? Or are avgDistance and energy related and you need to find the minimum and maximum of the relational function?
답변 (2개)
the cyclist
2011년 3월 25일
You have not adequately specified the problem, because the same array position might not have both minimum distance and maximum energy.
But surely you will need the function MIN and MAX, and maybe you can figure out how to get what you want using the help files for these two functions.
the cyclist
2011년 3월 26일
If your structure array is consecutively numbered (e.g element 1:N), then I think this will work for you:
[minDist indexToMinDist] = min([Snode.avgDistance])
[maxEnergy indexToMaxEnergy] = max([Snode.energy])
If not, you might need to do a little bit more to find the correct index, but maybe you get the idea.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!