Hello guys, I need help.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Everton Silva
el 27 de Mzo. de 2020
Comentada: Rik
el 28 de Mzo. de 2020
I need to evaluate the function in each combination of (x1, x2, x3), that is:
for i=1:11
for j=1:11
for k=1:11
z(i,j,k)=feval(f,x1(i),x2(j),x3(k));
end
end
end
This evaluation gives us an NxNxN matrix (cell?). I don't know what it's called hahahaha
[sfx, ind]=sort(z(:));
we selected the t smallest function values
sfx=sfx(1:t);
And the indexes corresponding to the t smallest function values
ind=ind(1:t);
Does anyone have any idea how I can return the values of x1, x2 and x3 corresponding to these t smallest function values?
4 comentarios
Guillaume
el 27 de Mzo. de 2020
Notes:
z(i,j,k)=feval(f,x1(i),x2(j),x3(k));
can be written more simply as
z(i,j,k)=f(x1(i),x2(j),x3(k));
assuming that f is a function handle.
Also, depending on f you may not need the loops at all.
Respuesta aceptada
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!