Last change
on this file since 36 was 27, checked in by Rick van der Zwet, 15 years ago |
Initial import of Practical Assigment data
|
File size:
903 bytes
|
Line | |
---|
1 | % An objective function for the low-autocorrelation problem.
|
---|
2 | % Author: Ofer M. Shir, 2004; oshir@liacs.nl.
|
---|
3 | %-----------------------------------------------------------------------
|
---|
4 | function [f] = autocorrelation(pop)
|
---|
5 | % Given a population of binary sequences, this function calculates
|
---|
6 | % the merit function according to the formula specified in the exercise description.
|
---|
7 | % The input pop is the given matrix.
|
---|
8 | % The output f is the merit factor calculated (row vector).
|
---|
9 |
|
---|
10 | n = size(pop,1);
|
---|
11 | m = size(pop,2);
|
---|
12 | E = zeros(1,m);
|
---|
13 |
|
---|
14 | % Calculated efficiently in a matrix-notation; auxilary matrices - Y1,Y2 - are
|
---|
15 | % initialized in every iteration. They are shifted form of the original y vectors.
|
---|
16 | % The diaganol of the dot-squared Y2*Y1 matrix is exactly the inner sum of merit function.
|
---|
17 | for k=1:n-1
|
---|
18 | Y1=pop(1:n-k,:);
|
---|
19 | Y2=pop(k+1:n,:)';
|
---|
20 | E=E+((diag(Y2*Y1)).^2)';
|
---|
21 | end
|
---|
22 |
|
---|
23 | % The output:
|
---|
24 | f = (n*n*ones(1,m))./(2*E);
|
---|
Note:
See
TracBrowser
for help on using the repository browser.