If I want to build a simple sine wave PSD in Matlab, I would do something like the following:
Fs = 1000; t = 0:1/Fs:1-(1/Fs); x = cos(2*pi*100*t) ; N = length(x); xdft = fft(x); xdft = xdft(1:N/2+1); psdx = (1/(Fs*N)) * abs(xdft).^2; psdx(2:end-1) = 2*psdx(2:end-1); freq = 0:Fs/length(x):Fs/2; plot(freq,10*log10(psdx)) grid on
But suppose for simplicity I have a sine wave generator in SIMULINK and I need to build a PSD. I did something like the following: 
Then I got a variable called "Sinwave", how can I apply the above Matlab code to build a PSD?
Note that the Sinewave variable is a 1x1 double time series. I tried just replacing x with Sinwave, but that didn't work.
Update: Applying Responses
I applied what I recommended, but I have a different result than if I did it with Matalb. Here is the code I used:
Fs = 1000; x = Sinwave.Data; N = length(x); dft = fft(x); dft = dft(1:N/2+1); psd = (1/(Fs*N)) * abs(dft).^2; psd(2:end-1) = 2*psd(2:end-1); freq = 0:Fs/length(x):Fs/2; plot(freq,10*log10(psd)) grid on
This one is for SIMULINK-exported sine wave 
However, one of the matlab code looks like this: 
I need the result to be the same as matalb , with all these ripples at the noise level . How can I get the exact result?
Please note that I used exact values ββfor both.
Update 2: setting the sine wave SIMULINK
1- Sine Wave Block

2- In workspace unit

3- Solver
