clear
clc

for i=1:20
    
    Amplitude(i)=exp((-(i-4)^2)./(2^2));

end

for k=1:20
    
    WaveNumber(k)=0.4*k;
    
end

SamplingRate=1000;

X=-100:1/SamplingRate:100;

for t=1:20
    
    Wave(t,1:length(X))=Amplitude(t)*sin(WaveNumber(t).*X);

end

SuperImposedWaves=Wave(1,1:length(X));

for p=2:20
    
    SuperImposedWaves=SuperImposedWaves+Wave(p,1:length(X));
    
end

figure(1);
subplot(2,1,1),plot(X,SuperImposedWaves);
title('TWENTY SuperImposed Waves, WaveNumbers: k=0.4 * (1...20)');
xlabel('Distance');
ylabel('Amplitude');
grid on

FreqXAxis=0:SamplingRate./((length(SuperImposedWaves)-1).*(2*pi)):SamplingRate;
Spectrum=abs(fft(SuperImposedWaves,length(SuperImposedWaves))./length(SuperImposedWaves));

subplot(2,1,2),plot(FreqXAxis(1:100),Spectrum(1:100),'r');
title('The Spectrum of the SuperImposed Waves, WaveNumbers: k=0.4*(1...20)');
xlabel('WaveNumber (k)');
ylabel('Magnitude');
grid on