Code covered by the BSD License  

Highlights from
System Identification using GA with a GUI interface

image thumbnail

System Identification using GA with a GUI interface

by

 

28 Jun 2006 (Updated )

Idnetifying ARX model of a system using Genetic Algorithms with a GUI interface and compare it to Le

fitness(gene)
function fit = fitness(gene)

%% Fitness evaluation
% This function evaluates the fitness of the passed gene for the system
% being identified
% fit = fitness(gene)
% gene ==> the gene passed
% fit  ==> the evaluated fitness of the gene
%
% Author: Wesam ELSHAMY
% wesamelshamy@ieee.org
% Electrical Engineering Dept., Cairo University, Egypt

global Na Nb Nk Y U

a = gene(1 : Na);               % extracting a parameters
b = gene(Na + 1 : Na + Nb);         % and b parameters

e = zeros(1, size(Y, 1));
for t = max(Na + 1, Nb + Nk) : size(Y, 1)
    e(t) = Y(t) + a*Y(t - Na : t - 1) - b*U(t - Nk - Nb + 1 : t - Nk); % ARX model
end
fit = sum(abs(e))/size(e, 2);  % and calculates the fitness

Contact us