Dear Hari
Here you are a simple version of a "feedback" structured AGC
clearvars; clc;
dt=0.001
t=0:dt:20;
A=10; f=0.25;
xin=A*sin(2*pi*f.*t);
L=round(10*f*(1/dt));
powerTarget=0.2;
yout=zeros(1,length(xin));
gainAGC=ones(1,length(xin));
for n=1:length(t)
yout(n)=gainAGC(n)*xin(n);
gainAGC(n+1)=gainAGC(n)*(1 - (1/L)*(yout(n)^2-powerTarget) );
end
figure;
subplot(2,1,1);
plot(t, xin, '-b'); hold on;
plot(t, yout, '-r'); zoom on; grid on;
xlabel('t in sec'); ylabel('amplitude');
legend('xin', 'yout'); title('AGC input and output');
subplot(2,1,2);
plot(t, gainAGC(1:end-1)); zoom on; grid on;
title('gain of AGC');
I have choosen a very simple version of gain adaptation.
Keep in mind that parameter L controls the speed of AGC lock. Large values of L leads to a fast but noisy convergence.
If you run this code, with the parameters I've choosen, you will get the following results:
5 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/479137-about-implementing-a-agc#comment_742773
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/479137-about-implementing-a-agc#comment_742773
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/479137-about-implementing-a-agc#comment_742834
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/479137-about-implementing-a-agc#comment_742834
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/479137-about-implementing-a-agc#comment_812570
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/479137-about-implementing-a-agc#comment_812570
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/479137-about-implementing-a-agc#comment_815661
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/479137-about-implementing-a-agc#comment_815661
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/479137-about-implementing-a-agc#comment_815887
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/479137-about-implementing-a-agc#comment_815887
Sign in to comment.