In the code below, what does ind do?

cost=feval(ff,pop); %evaluate function
[cost,ind]=sort(cost,'descend'); %sorts in descending order
pop=pop(ind,:);

 Respuesta aceptada

Star Strider
Star Strider el 9 de Dic. de 2018

1 voto

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’.

Más respuestas (0)

Preguntada:

el 9 de Dic. de 2018

Respondida:

el 9 de Dic. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by