# Power Spectrum Estimation of three sinusoids in white noise

Let's assume we have a random process consisting of three sinusoids in white noise: $$x[n] = 3 \cdot \sin(ω_1 \cdot n + ϕ_1) + 5 \cdot \cos(ω_2 \cdot n + ϕ_2) + 2 \cdot \sin(ω_3 \cdot n + ϕ_3) + v[n]$$ where $$ϕ_1$$, $$ϕ_2$$, $$ϕ_3$$ are uncorrelated uniformly distributed random variables in $$[0,2\pi]$$

I want to estimate the power spectral density of $$x[n]$$. For that purpose I apply two different methods:

1. Periodiagram of $$x[n]$$
2. Welch method (Averaged Modified Periodogram) using Hamming window

I generated the following code and ran in Matlab:

N = 1024;
w1 = 0.3 * pi;
w2 = 0.6 * pi;
w3 = 0.7 * pi;
phi1 = unifrnd(0, 2*pi);
phi2 = unifrnd(0, 2*pi);
phi3 = unifrnd(0, 2*pi);
u = randn(1, N);
n = 0:N-1;
x = 3 * sin(w1*n + phi1) + 5*cos(w2*n + phi2) + 2*sin(w3*n + phi3) + u;

fig = figure;
plot(n,x);
title('signal x[n]');
xlabel('samples');
ylabel ('Magnitude');

fig=figure;
[p,f]=periodogram(x);
plot(f,p);

fig=figure
[pw,f]= pwelch(x, N/8, N/16);
plot(f,pw);


Which is the difference in these two methods about the resolution and the variance of the power spectrum ?

• Thanks for the response! I would like to ask something more. Whis is the correct way to produce the standard periodogram and the Welch's modification to the standard Periodogram in Matlab code? In my example I used the commands: [p,f]=periodogram(x); plot(f,p); However, I get a different result when I just write the command periodogram(x) .. Which one should I keep as an answer? Same for the Welch diagram. – MJ13 Jun 2 '19 at 8:24
• Honestly I get the same results from [p,f] = periodogram(x) and p = periodogram(x) ... Hence I don't know why you get different results. – Fat32 Jun 2 '19 at 20:45
• Actually the result is different if you change both of the instructions: [p,f]=periodogram(x); plot(f,p); with the instruction periodogram(x). Which is the correct one? – MJ13 Jun 3 '19 at 17:01