LTPDA Toolbox™ | contents | ![]() ![]() |
Saving and loading objects in LTPDA is straightforward. You have two formats available to you: the standard MATLAB .mat binary format, or the text-based XML format.
Suppose you have an AO in your MATLAB workspace, you can save it to disk like this:
% Generate a time-series of random numbers a = ao.randn(10, 10); % Save to a file called 'a.mat' save(a);
% Generate a time-series of random numbers a = ao.randn(10, 10); % Save the AO to a MAT file save(a, 'myNiceAO.mat');
f = miir(plist('type', 'lowpass', 'fc', 0.1, 'fs', 10, 'order', 1)) save(f, plist('filename', 'myNiceFilter.mat'));
You can save multiple objects in to one file with LTPDA:
a1 = ao.randn(10, 10); a2 = ao.randn(10, 100); save(a1, a2, 'myObjects.mat'); % If you have a vector of objects... a = [a1 a2]; save(a, 'myVectorOfObjects.mat');
a1 = ao(plist('waveform', 'sine wave', 'a', 1, 'f', 1, 'phi', pi/2, 'fs', 50, 'nsecs', 10, 'name', 'sig1')) a2 = ao(plist('waveform', 'sine wave', 'a', 1, 'f', 0.2, 'phi', pi/4, 'fs', 50, 'nsecs', 10, 'name', 'sig2')) a = [a1 a2]; save(a, plist('individual files', true));
a1 = ao(plist('waveform', 'sine wave', 'a', 1, 'f', 1, 'phi', pi/2, 'fs', 50, 'nsecs', 10, 'name', 'sig1')) a2 = ao(plist('waveform', 'sine wave', 'a', 1, 'f', 0.2, 'phi', pi/4, 'fs', 50, 'nsecs', 10, 'name', 'sig2')) a = [a1 a2]; save(a, plist('filename', 'myAOs.xml', 'individual files', true));
Loading objects from disk is typically done using the relevant constructor. However, this does imply that you know the class of the object in the file on disk. If you don't, you need to try to load with a particular constructor (say, AO) then if that is not correct, the error message will tell you the class of the object in the file.
Let's load one of the AOs we saved above:
a = ao('myNiceAO.mat');
>> a = ao('myNiceFilter.mat');
Error using ltpda_uo/fromFile (line 174)
You tried to load objects of class [ao] from myNiceFilter.mat, but that file contains objects of class [miir]
Error in ao (line 348)
obj = fromFile(obj, args{1});
![]() |
Introducing objects in LTPDA | Review of spectral estimators | ![]() |
©LTP Team