Clear Filters
Clear Filters

How do I export spectral data generated in Time Series Tools to the MATLAB workspace or to a file?

2 views (last 30 days)
I am using Time Series Tools (>>tstool ) in MATLAB. I would like to export the spectral data generated from a time series data set when creating a spectral plot. My target is the workspace or a file.
I can do this with the time series data itself, but cannot seem to do it with spectral data.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 21 Jan 2010
The ability to export spectral data to the MATLAB workspace or a file is unavailable in MATLAB 7.1 (R14SP3).
A workaround is to access the API of the Time Series Tools GUI, as follows.
Once the spectral plot is generated, click on Spectral View in the session tree and then call the following function from the MATLAB command line.
>> s = exportSpecData
This function EXPORTSPECDATA can be created as follows:
s = function exportSpecData
h = tstool;
n = h.TreeManager.getselectednode;
for k=1:length(n.Plot.Waves)
s(k).Name = n.Plot.Waves(1).Name;
s(k).Frequency = n.Plot.Waves(1).Data.Frequency;
s(k).Spectrum = n.Plot.Waves(1).Data.Response;
end
Notes:
1. This function accesses the API of the Time Series Tools, and this API is subject to change in future releases of MATLAB. Consequently, this method is not supported.
2. The Spectral View item must be selected in Time Series Tools before the exportSpecData function is called. Otherwise, an error will be produced. Select Time Series Session Tree --> Views --> Spectral Plots --> View1, and then call the function.
The code above is available in the attached file, 'exportSpecData.m'.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!