Effacer les filtres
Effacer les filtres

Function with many outputs

2 vues (au cours des 30 derniers jours)
B.E.
B.E. le 26 Jan 2023
Commenté : B.E. le 26 Jan 2023
I have this function [Y_1,Y_2,Y_3,Y_4]=MyFun(X);
I want to optimize X according to this cost function using ga function of Matlab
J=@(X) Y_1.^2+Y_2.^2;
X=ga(J,numel(X));
How to write the cost function J knowing that Y_1 and Y_2 depend on X.

Réponse acceptée

Torsten
Torsten le 26 Jan 2023
X=ga(@cost,numel(X));
function J = cost(X);
[Y_1,Y_2] = MyFun(X);
J = Y_1.^2+Y_2.^2;
end
  1 commentaire
B.E.
B.E. le 26 Jan 2023
Thank you

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Problem-Based Optimization Setup dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by