For exponential signals (sine or cosine), if the sampling frequency $f_s$ is equal to the length of signal, $N$, the magnitude of psd for each sine signal is proportional to amplitude in time domain, while if $f_s$ is not equal to length of signal $N$, for example here, $f_s=1000 \text{Hz}$, the magnitude of sine signals in psd (frequency domain) is not proportional to their original signal. The MATLAB code is provided.
Can you tell me the reason? Is this something related with leakage?
N=256;
x0=zeros(N,1);
fs=1000;
idx = (0:(N-1))'; % Indices
f=20*[1 2 3 4];
A=[1 2 3 4];
K=4;
for ii=1:K
x0=x0+A(ii)*exp(sqrt(-1)*2*pi*f(ii)*idx/fs);
end
X=fft(x0);
figure;
plot(abs(X).^2)