MATLAB: Periodogram example code

periodogram

I am trying to get to grips with plotting a periodogram of a financial time series using Matlab. My first port of call was the product documentation for the periodogram on the mathworks website, http://www.mathworks.com/help/toolbox/signal/periodogram.html.
So I went and copied there example code into Matlab, below
Fs = 1000;
t = 0:1/Fs:.3;
x = cos(2*pi*t*200)+0.1*randn(size(t));
periodogram(x,[],'onesided',512,Fs)
but this just gives me an error
??? Attempt to execute SCRIPT periodogram as a function:
C:\Users\Currys\Documents\MATLAB\periodogram.m
what did I do wrong? How can I get to see this example code in practice?

Best Answer

You wrote a script called 'periodogram.m' located at C:\Users\Currys\Documents\MATLAB\periodogram.m.
It's trying to call your script. Change your script's name to something else and then run it.