t=0:.01:20*pi;

num_waves=49;

amplitude_basis=ceil(num_waves/2)^2;

amplitudesa=[1:ceil(num_waves/2)];
amplitudesb=[floor(num_waves/2):-1:1];
amplitudes=[amplitudesa,amplitudesb];

for i=1:num_waves
    y(:,i)=cos((i+3)*t');
    y2(:,i)=amplitudes(i)*cos((i+3)*t');
end

Y=sum(y');
Y2=sum(y2');
Y=Y/max(Y);
Y2=Y2/max(Y2);
figure
plot(Y)
hold on
plot(Y2,'r')
