In the code below, what does ind do?

15 ビュー (過去 30 日間)
Ifeatu Ezenwe
Ifeatu Ezenwe 2018 年 12 月 9 日
回答済み: Star Strider 2018 年 12 月 9 日
cost=feval(ff,pop); %evaluate function
[cost,ind]=sort(cost,'descend'); %sorts in descending order
pop=pop(ind,:);

採用された回答

Star Strider
Star Strider 2018 年 12 月 9 日
It evaluates a function called ‘ff’ with the argument ‘pop’, and assigns it to the variable ‘cost’. It then sorts ‘cost’, gets the associated indices (‘ind’)into the original vector, and uses those indices to re-define ‘pop’, sorting it according to ’cost’.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by