about fitness function gatool

조회 수: 2 (최근 30일)
Natalia
Natalia 2012년 1월 21일
Hello! I have a fitness function
function z = my_fun(x)
Visot1 = readfis('Visot1'); %read fis-file to workspace
Visot1.input(1,1).mf(1,1).params=[x(1),x(2),x(3)]; %rewrite params of fis-file
sim('sfundebug.mdl'); %simulate a simulink model, which use fis-file and write to workspace "simout.signals.values"
z = sqrt(sum((simout.signals.values).^2)/(length(simout.signals.values)));
But then I use it, I have an error "Error due to multiple causes." When I do 'dbstop if error', it stop at sim('sfundebug.mdl'); and simulate don't work. If I do Visot1 = readfis('Visot1'); in command line before use gatool, sim('sfundebug.mdl'); is work, but it use the old params of Visot1. Do not rewrite params of fis-file... Do not understand... Thanks for any answer :) Natalia

답변 (2개)

Egor
Egor 2012년 4월 9일
Hi! Have you solved this problem? Any hints?

john
john 2013년 2월 1일
I have same problem but fortunately problem Solved! :D I used below commands instead of sim() command :
opt = simset('solver','ode45','SrcWorkspace','Current');
[tout,xout,yout] = sim('YourModelName',[0 20],opt);
also you should add some 'outport' to your model in order to save their values during the optimization for calculating Objective Function. you can find more information about this on page 36 (1-20) of below link:
I'll hope it works for you either good luck

카테고리

Help CenterFile Exchange에서 Fuzzy Logic in Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by