The ability to set frequency units to "cyc/month" (/quarter or /year) is not available in the TSTOOL in MATLAB 7.9 (R2009b).
As a workaround, you might want to create the spectral plot manually computing the data with FFT, SPECTROGRAM or PERIODOGRAM, and customize the format and scale of your figures accordingly. You can set the frequency units using the XLABEL command. For example:
delta = pi/8;
time = 0:delta:8*pi;
data = sin(time)+0.5*rand(size(time))-0.25;
ts = timeseries(data, time);
f = fft(data);
f = abs(f.^2);
f = f(1:ceil(numel(f)/2));
freq_max = 1/(2*delta);
freq = linspace(0, freq_max, numel(f));
scale = 604800*4.3;
freq = freq*scale;
figure; plot(freq, f)
xlabel('Freq (cyc/month)')
Alternatively, you can modify the properties of the spectral plot as follows. However, since these changes are made outside of TSTOOL, note that subsequent modifications to the plot using the TSTOOL may lead to incorrect results.
This example assumes that the units in the spectral plot are currently set to "cyc/week", the data is to be viewed with units "cyc/month", and there are 4.3 weeks in a month.
Execute the following at the MATLAB command prompt:
f = findall(0, 'Type', 'figure', 'Name', 'Spectral plot: View1');
a = findall(f, 'Type', 'axes', 'Visible', 'on', 'Tag', '');
l = findall(a, 'Type', 'line');
xdata_all = get(l, 'XData');
for idx = 1:numel(xdata_all)
xdata = xdata_all{idx};
if ~isempty(xdata) && ~isnan(xdata(1))
l = l(idx);
break
end
end
xlim = get(a, 'XLim');
set(a, 'XLim', xlim*4.3);
xdata = xdata*4.3;
set(l, 'Xdata', xdata)
xlabel(a, 'Freq (cyc/month)')
Best Answer