Mercurial > hg > ltpda
view m-toolbox/test/test_ao_size_on_xml.m @ 33:5e7477b94d94 database-connection-manager
Add known repositories list to LTPDAPreferences
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Mon, 05 Dec 2011 16:20:06 +0100 |
parents | f0afece42f48 |
children |
line wrap: on
line source
function out = test_ao_size_on_xml(load, tsdata_sizes) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % DESCRIPTION: TEST_AO_SIZE_ON_XML Test of the size of aos when stored to % disk as xml files, as a function of the number of samples % % CALL: o = test_ao_size_on_xml(load, tsdata_sizes) % % INPUTS: load - skips the evaluation phase and only load results % tsdata_sizes - array of lengths of % % OUTPUTS: out - a matrix with the lenghts of ao (samples) and % curresponding xml file size (bytes) % % VERSION: $Id: test_ao_size_on_xml.m,v 1.2 2008/03/06 10:06:18 mauro Exp $ % % HISTORY: 05-03-2008 M Hueller % Creation % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ALGONAME = mfilename; VERSION = '$Id: test_ao_size_on_xml.m,v 1.2 2008/03/06 10:06:18 mauro Exp $'; CATEGORY = 'Helper'; dir_name = 'c:\data\profile\'; file_name = 'ao_xml_size'; if ~load % Tsdata sampling rate fs = 10; % Sinewave amplitude, frequency, phase A = 1; f_m = 0.1; phi = 0; for jj = 1:length(tsdata_sizes) % Calculate the number of seconds for the required size and sampling % rate nsecs = tsdata_sizes(jj)/fs; disp([' ']); disp(['ao with ' num2str(nsecs*fs) ' samples']); disp([' ']); % Evaluates the test data aos a = ao(plist('waveform', 'sine wave', ... 'fs', fs, ... 'nsecs', nsecs, ... 'A', A, ... 'f', f_m, ... 'phi', phi)); % Saves the test data ao on xml format, adding the length to its name save(a, [dir_name file_name '_' num2str(nsecs*fs) '.xml']); end else % Recall the sampling rate from the ao itself a = ao([dir_name file_name '_' num2str(tsdata_sizes(end)) '.xml']); fs = a.data.fs; end % Gets the list of the files produced for the test, skipping '.' and '..' list = dir(dir_name); list = list(3:end); sizes = []; lens = []; % Loops over the files found in the directory for jj = 1:length(list) indx = findstr(list(jj).name, '_'); start = indx(end) + 1; stop = findstr(list(jj).name, '.') - 1; % Recover the test ao length from its name len = str2double(list(jj).name(start:stop)); % Checks if the length is in the list given by user for kk = 1:length(tsdata_sizes) if len == tsdata_sizes(kk) lens = [lens;len]; sizes = [sizes;list(jj).bytes]; end end end figure; plot(lens, sizes, 'k.','MarkerSize',8); grid on; xlabel('Samples'); ylabel('xml file size (bytes)') legend(['tsdata at ' num2str(fs) ' Hz']); out = [lens sizes];