% Attenuation signal 
alpha=300;      % alpha:attenuation constant
fc=200;    % fc:carrier frequency
% obserbvation time: 0 to 20ms
% Number of samples: N1=100samples
N1=100;
t1=linspace(0, 0.02, N1);
s1=exp(-alpha*t1).*sin(2*pi*fc*t1);
figure(1);
plot(t1,s1);grid on
xlabel('Time [sec]');
ylabel('Attenuation signal s1(t)');
% Different frequency : 220Hz
% Different alpha: 330
fc=220;
alpha=330;
N2=100;
t2=linspace(0, 0.02, N2);
s2=exp(-alpha*t2).*sin(2*pi*fc*t2);
figure(2);
plot(t2,s2);grid on
xlabel('Time [sec]');
ylabel('Attenuation signal s2(t)');


% Enlarge 110%
dt2=0.02/(N2-1)*1.1;
t2=t2*1.1;
% Linear interpolation s2(1:100) ==> s3(1:100)
N3=100;
dt1=0.02/(100-1);
for j=1: N3
    t3(j)=0.02/(N3)*(j-1);
    i=fix(t3(j)/dt2)+1;
    a=abs(t2(i)-t3(j))/dt2;
    b=abs(t2(i+1)-t3(j))/dt2;
    s3(j)=b*s2(i)+a*s2(i+1);
end
figure(3);
plot(t3,s3);grid on
xlabel('Time [sec]');
ylabel('Interporated and Enlarged attenuation signal s3(t)');
