MATLAB Answers

Problem concerning the fitness function of the genetic algorithm on MATLAB.

조회 수: 32(최근 30일)
Oma Leo
Oma Leo 14 Feb 2021
댓글: Oma Leo 16 Feb 2021
Hi everyone,
I need your help for this problem. The fitness function I am considering for my project is the error between two output signals of two simulink models and it has to be the smallest possibile. This is a piece of the code I wrote.
where iHF is a .mat file with dimension 2x50001, iLF is a normal output array with dimension 50001x1 and simulation.DT is the sampling time equal to 1e-5.
The formula to calculate the error is the following:
When I run the matlab code containing the optimization parameters, it gives me an error saying "Your fitness function must return a scalar value".
What should I do?

채택된 답변

Matt J
Matt J 15 Feb 2021
편집: Matt J 15 Feb 2021
Make y1 and y2 the same size and shape (i.e., make sure both are row vectors or both column vectors).

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by