function [varianceScalewiseValues, rootFirstValues] = SeriesOfScalarBinary(auData, scalingRatio,elementNum)
%%% File: SeriesOfScalarBinary.m
%%
%% -------------- ---------------
%%
%% The function of this subroutine is to write series of scalar
%% with a uniform power-of-two ScaleRatio in a XML file.
%% The restriction to a power-of-two ratio eases the comparison
%% of series with different ScaleRatios. It also allows an additional
%% scaling operation to be defined (scalewise variance), and allows
%% the data to be coded in "rootFirst" format
%%
%%
%%
%%
%%
%%
%%
%%
%%
%% Function:
%% SeriesOfScalarBinary: A representation of a series of scalar values scaled by
%% a power of two factor.
%% Outputs:
%% VarianceScalewise: Optional array of arrays of scalewise variance coefficients.
%% Scalewise variance is a decomposition of the variance into
%% a series of coefficients, each of which describes the variability
%% at a particular scale. There are log2(ratio) such coefficients.
%% Number of rows must equal 'NumElements', number of columns must
%% equal the number of coefficients of the scalewise variance.
%% rootFirst: Optional flag. If true, the series are recorded in "root-first" format.
%% This format is defined below. In brief: the recorded series starts
%% with the grand mean of the original series, and the subsequent values
%% provide a progressively refined description from which the entire series
%% can be reconstructed.
%% Inputs:
%% auData: Incoming signal
%% scaligRatio: Scale factor
%% elementNum: Elements Number
%%
%% (N3704)
%%
%%
%% Copyright (c), IME, All Rights Reserved
%%
%% Author: Dong Yan Huang
%% Version: 1.0 Time: 28 October 2000 (N3489)
%% Last Modified: 27 Mar 2001 (N3704)
%if nargin < 5, error('constr requires five input arguments'); end
%if nargin < 6, weight_flag = 0; weight= []; end
%global fid;
fid = fopen('SeriesOfScalarBinary.xml','w');
x='';
fprintf(fid, '%s\n',x);
x='';
fprintf(fid, '%s\n',x);
x='';
fprintf(fid, '%s\n',x);
x='
x = ' 1';
fprintf(fid,'%s\n',x);
if rootFirst == 1
x = strcat(' ');
fprintf(fid,'%s\n',x);
x= strcat(' ');
fprintf(fid,'%s\n',x);
rootFirstValues = h_rootFirst_SeriesOfScalarBinary(auData,scalingRatio, elementNum);
varianceScalewiseValues = [];
x = strcat(' ', num2str(rootFirstValues),'');
fprintf(fid,'%s\n',x);
x =' ';
fprintf(fid,'%s\n',x);
%fprintf(fid, '%s \n',x);
x = strcat('');
fprintf(fid, '%s \n',x);
else
x = strcat(' ');
fprintf(fid,'%s\n',x);
x = strcat(' ');
fprintf(fid,'%s\n',x);
rootFirstValues = h_rootFirst_SeriesOfScalarBinary(auData,scalingRatio, elementNum);
varianceScalewiseValues= h_SWVariance_SeriesOfScalarBinary(auData,scalingRatio, elementNum);
x = strcat(' ', num2str(rootFirstValues(1)), ' ');
fprintf(fid, '%s \n',x);
x = strcat(' ', num2str(varianceScalewiseValues));
fprintf(fid, '%s \n',x);
x =' ';
fprintf(fid, '%s \n',x);
x = '';
fprintf(fid, '%s \n',x);
x = strcat('');
fprintf(fid, '%s \n',x);
end
fclose(fid);