Not sure about my fitness function works
1 view (last 30 days)
Show older comments
Hi, I want to calculate coefficients for Farrow structure and I want to use ga as I saw in some papers. But I'm not sure that I wrote fitness function well. The aim is minimazing the frequency response respect to ideal one, in particular minimazing magnitude and phase for each value of discretized frequency and fractional delay. Here I post the code about fitness function.
function error = fitness_farrow( h )
M = 3;
Nh = 10;
for m=1:M+1
hd(m,:) = h((m-1)*Nh+m:m*Nh+m); % put variables h in matrix form MxN
end
alpha = 0.8;
wl = 0:0.1:alpha*pi;
Q = 1000;
dpq = (0:1:Q-1)/Q;
error = 0;
for i=1:length(dpq)
for u=1:length(wl)
sum_m = 0;
for m=1:M+1
sum_n = 0;
for n=1:Nh+1
coeff = hd(m,n).*exp(-1i* wl(u)*(n-1)) ;
sum_n = sum_n + coeff;
end
coeff_m = sum_n .* dpq(i)^(m-1);
sum_m = sum_m + coeff_m;
end
error_a = abs( abs(sum_m) - 1 ) ;
error_p = abs( dpq(i) - angle(sum_m)/wl(u) );
obj_fun = error_a + error_p;
error = error + obj_fun ;
end
end
end
0 Comments
Answers (0)
See Also
Categories
Find more on Read, Write, and Modify Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!