Filter löschen
Filter löschen

maximization of a function of 2 variables

1 Ansicht (letzte 30 Tage)
Basanta
Basanta am 25 Mär. 2011
I have two arrays ,
avgDistance and energy
I need to find out the array position with minimum avgDistance and maximum energy.
help me.....
  1 Kommentar
Anathea Pepperl
Anathea Pepperl am 25 Mär. 2011
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?

Melden Sie sich an, um zu kommentieren.

Antworten (2)

the cyclist
the cyclist am 25 Mär. 2011
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.
  1 Kommentar
Basanta
Basanta am 26 Mär. 2011
ok, let me clarify it,...
I have an array of structure Snode. The Snode structure has many fields including the avgDistance and energy.
I need to find out the array index of that structure having minimum avgDistance and maximum energy.
please help...

Melden Sie sich an, um zu kommentieren.


the cyclist
the cyclist am 26 Mär. 2011
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.

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by