Error in optimization with GA: Struct contents reference from a non-struct array object

Hi, I'm new to Matlab and Simulink. I am going to optimize my Simulink model using the genetic algorithm.
The optimization can run, but it does not work at the plot of the results for each GA-generations. When the optimization ends, I can not obtain the best result with the optimal variables. The only thing is an error:
Error running optimization. Struct contents reference from a non-struct array object.
Here is my function:
function grades = rules(Vars)
........
........
% Data from Simulink model
[y] =sim('Model',1000);
% Data are imported from Data file
load('uH.mat');
x_d = y(1:8001,1);
x_ud = uH(1:8001,2);
RMS_1 = sqrt(sum(x_d.*x_d)/8001);
RMS_2 = sqrt(sum(x_ud.*x_ud)/8001);
% fitness function
grade_RMS_x = (RMS_x_ud - RMS_x_d) / RMS_x_ud;
grades = 1 - grade_RMS_x;
end
It would be perfect if someone could help me out. :) Thank you so so much!

2 件のコメント

Walter Roberson
Walter Roberson 2017 年 9 月 6 日
Is uH.mat being written by the model using a ToFile block? Then if so note that the default is to write as a Timeseries object https://www.mathworks.com/help/simulink/slref/tofile.html and that even if you specify Array that the first column will be timestamps.
Junyu Chen
Junyu Chen 2017 年 9 月 7 日
sry, no. uH.mat is imported from an external file. :(

サインインしてコメントする。

回答 (0 件)

カテゴリ

質問済み:

2017 年 9 月 6 日

編集済み:

2017 年 9 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by