about fitness function gatool

2 visualizzazioni (ultimi 30 giorni)
Natalia
Natalia il 21 Gen 2012
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

Risposte (2)

Egor
Egor il 9 Apr 2012
Hi! Have you solved this problem? Any hints?

john
john il 1 Feb 2013
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

Categorie

Scopri di più su Fuzzy Logic in Simulink in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by