Commit 1a148cee authored by Florian Kaltenberger's avatar Florian Kaltenberger

first commit including OFDM, SCFMDA, GFDM, (5MHz) and UFMC (10MHz) waveforms

parents
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
[submodule "wiki"]
path = wiki
url = ./wiki
function [varargout] = dirrec(reper,ext)
%
% Find files recursively in a given folder.
%
% C=dirrec('c:\windows') returns a cell C with the full pathname of all
% files in the c:\windows folder and all its sub-folders.
%
% C=dirrec('c:\windows','.exe') idem but returns only the files with
% extension .exe.
%
% C=dirrec('c:\windows','co*') idem but returns only the files starting with
% the two letters co (comsetup.log, control.ini, ...).
%
% C=dirrec('c:\windows',{'.exe','.dll') idem but returns files with both
% .exe and .dll extensions.
%
% dirrec('c:\windows','.cmd') only displays the list of the .cmd files in
% the Matlab command window
%
% c:\windows\system32\login.cmd
% c:\windows\system32\usrlogon.cmd
%
% Note that extension should be given in lower case.
%
% See also DIR.
%
% Luc Masset (2007)
% Algorithm:
% The three cases - no extension, one extension and multiple extensions - are separeted to speed up the
% search process. The function fileextDR replaces the fileparts function because we only need the
% extension.
%initialisation
if nargout,
varargout=[];
end
listF=[];
%input arguments
if ~nargin | nargin > 2,
error('DIRREC requires 1 or two arguments')
return
elseif nargin == 1,
ext=[];
else
if ~iscell(ext),
if strcmpi(ext,'.*'),
ext=[];
end
end
end
%list of folders
listD{1,1}=reper; % a cell containing all the searched folders
indD(1)=1; % a vector (same size as listD) indicating
% that a folder has been searched (1) or not (0)
%cases
if isempty(ext),
icase=1;
elseif ~iscell(ext),
ii=strfind(ext,'*');
if length(ii) == 1 & ii == length(ext);
icase=2;
else
icase=3;
end
elseif iscell(ext),
icase=4;
else
ext=[];
icase=1;
end
%case 1: no extension given
switch icase
case 1,
while 1,
ind=find(indD);
if isempty(ind),
break;
end
ind=ind(1);
rep=listD{ind};
[listdir,listfile]=getdirDR1(rep);
listF=[listF listfile];
indD(ind)=0;
nbd=length(listdir);
if nbd,
listD=[listD listdir];
indD=[indD ones(1,nbd)];
end
end
%case 2: start of the name given (--*)
case 2,
stc=strrep(ext,'*','');
while 1,
ind=find(indD);
if isempty(ind),
break;
end
ind=ind(1);
rep=listD{ind};
[listdir,listfile]=getdirDR4(rep,stc);
listF=[listF listfile];
indD(ind)=0;
nbd=length(listdir);
if nbd,
listD=[listD listdir];
indD=[indD ones(1,nbd)];
end
end
%case 3: only one extension given
case 3,
while 1,
ind=find(indD);
if isempty(ind),
break;
end
ind=ind(1);
rep=listD{ind};
[listdir,listfile]=getdirDR2(rep,ext);
listF=[listF listfile];
indD(ind)=0;
nbd=length(listdir);
if nbd,
listD=[listD listdir];
indD=[indD ones(1,nbd)];
end
end
%case 4: several extensions given
case 4,
while 1,
ind=find(indD);
if isempty(ind),
break;
end
ind=ind(1);
rep=listD{ind};
[listdir,listfile]=getdirDR3(rep,ext);
listF=[listF listfile];
indD(ind)=0;
nbd=length(listdir);
if nbd,
listD=[listD listdir];
indD=[indD ones(1,nbd)];
end
end
end
%display results
if ~nargout,
for i=1:length(listF),
fprintf('%s\n',listF{i});
end
else
varargout{1}=listF;
end
return
%------------------------------------------------------------------------------
function [listdir,listfile] = getdirDR1(reper)
%dir of folder reper
S=dir(reper);
%separate sub-folders of reper and files
n=size(S,1);
listdir=cell(1,n); % list of sub-folders
listfile=cell(1,n); % list of files
for i=1:n,
name=S(i).name;
if S(i).isdir,
if strcmp(name,'.'), % remove current folder (.)
continue;
end
if strcmp(name,'..'), % remove parent folder (..)
continue;
end
listdir{i}=fullfile(reper,S(i).name);
else
listfile{i}=fullfile(reper,S(i).name);
end
end
%reorder results
ind=find(cellfun('isempty',listdir));
listdir(ind)=[];
ind=find(cellfun('isempty',listfile));
listfile(ind)=[];
return
%------------------------------------------------------------------------------
function [listdir,listfile] = getdirDR2(reper,ext)
%dir of folder reper
S=dir(reper);
%separate sub-folders of reper and files
n=size(S,1);
listdir=cell(1,n); % list of sub-folders
listfile=cell(1,n); % list of files
nd=0;
nf=0;
for i=1:n,
name=S(i).name;
if S(i).isdir,
if strcmp(name,'.'), % remove current folder (.)
continue;
end
if strcmp(name,'..'), % remove parent folder (..)
continue;
end
nd=nd+1;
listdir{nd}=fullfile(reper,S(i).name);
else
exte=fileextDR(name); % compare extension
if strcmpi(exte,ext), % with given extension
nf=nf+1;
listfile{nf}=fullfile(reper,S(i).name);
end
end
end
%reorder results
listdir(nd+1:end)=[];
listfile(nf+1:end)=[];
return
%------------------------------------------------------------------------------
function [listdir,listfile] = getdirDR3(reper,ext)
%dir of folder reper
S=dir(reper);
%separate sub-folders of reper and files
n=size(S,1);
listdir=cell(1,n); % list of sub-folders
listfile=cell(1,n); % list of files
for i=1:n,
name=S(i).name;
if S(i).isdir,
if strcmp(name,'.'), % remove current folder (.)
continue;
end
if strcmp(name,'..'), % remove parent folder (..)
continue;
end
listdir{i}=fullfile(reper,S(i).name);
else
exte=fileextDR(name); % extension of the file
if isempty(exte),
continue;
end
if strmatch(lower(exte),ext,'exact'), % compare extension with given extensions
listfile{i}=fullfile(reper,S(i).name);
end
end
end
%reorder results
ind=find(cellfun('isempty',listdir));
listdir(ind)=[];
ind=find(cellfun('isempty',listfile));
listfile(ind)=[];
return
%------------------------------------------------------------------------------
function [listdir,listfile] = getdirDR4(reper,stc)
%dir of folder reper
S=dir(reper);
%separate sub-folders of reper and files
n=size(S,1);
listdir=cell(1,n); % list of sub-folders
listfile=cell(1,n); % list of files
nd=0;
nf=0;
for i=1:n,
name=S(i).name;
if S(i).isdir,
if strcmp(name,'.'), % remove current folder (.)
continue;
end
if strcmp(name,'..'), % remove parent folder (..)
continue;
end
nd=nd+1;
listdir{nd}=fullfile(reper,S(i).name);
else
ii=strfind(name,stc);
if isempty(ii) | ii ~= 1,
continue;
end
nf=nf+1;
listfile{nf}=fullfile(reper,S(i).name);
end
end
%reorder results
listdir(nd+1:end)=[];
listfile(nf+1:end)=[];
return
%------------------------------------------------------------------------------
function [ext] = fileextDR(fname)
ext=[];
ind=strfind(fname,filesep);
if ~isempty(ind),
fname=fname(max(ind)+1:end);
end
ind=strfind(fname,'.');
if isempty(ind),
return
end
ext=fname(max(ind):end);
return
% UTILS Utility package for MATLAB xUnit Test Framework
%
% Array Comparison
% compareFloats - Compare floating-point arrays using tolerance
%
% Test Case Discovery Functions
% isTestCaseSubclass - True for name of TestCase subclass
%
% String Functions
% arrayToString - Convert array to string for display
% comparisonMessage - Assertion message string for comparing two arrays
% containsRegexp - True if string contains regular expression
% isSetUpString - True for string that looks like a setup function
% isTearDownString - True for string that looks like teardown function
% isTestString - True for string that looks like a test function
% stringToCellArray - Convert string to cell array of strings
%
% Miscellaneous Functions
% generateDoc - Publish test scripts in mtest/doc
% parseFloatAssertInputs - Common input-parsing logic for several functions
% Steven L. Eddins
% Copyright 2008-2009 The MathWorks, Inc.
function s = arrayToString(A)
%arrayToString Convert array to string for display.
% S = arrayToString(A) converts the array A into a string suitable for
% including in assertion messages. Small arrays are converted using disp(A).
% Large arrays are displayed similar to the way structure field values display
% using disp.
% Steven L. Eddins
% Copyright 2009 The MathWorks, Inc.
if isTooBigToDisp(A)
s = dispAsStructField(A);
else
s = dispAsArray(A);
end
%===============================================================================
function tf = isTooBigToDisp(A)
% Use a heuristic to determine if the array is to convert to a string using
% disp. The heuristic is based on the size of the array in bytes, as reported
% by the whos function.
whos_output = whos('A');
byte_threshold = 1000;
tf = whos_output.bytes > byte_threshold;
%===============================================================================
function s = dispAsArray(A)
% Convert A to a string using disp. Remove leading and trailing blank lines.
s = evalc('disp(A)');
if isempty(s)
% disp displays nothing for some kinds of empty arrays.
s = dispAsStructField(A);
else
s = postprocessDisp(s);
end
%===============================================================================
function s = dispAsStructField(A)
% Convert A to a string using structure field display.
b.A = A;
s = evalc('disp(b)');
s = postprocessStructDisp(s);
%===============================================================================
function out = postprocessDisp(in)
% Remove leading and trailing blank lines from input string. Don't include a
% newline at the end.
lines = xunit.utils.stringToCellArray(in);
% Remove leading blank lines.
lines = removeLeadingBlankLines(lines);
% Remove trailing blank lines.
while ~isempty(lines) && isBlankLine(lines{end})
lines(end) = [];
end
% Convert cell of strings to single string with newlines. Don't put a newline
% at the end.
out = sprintf('%s\n', lines{1:end-1});
out = [out, lines{end}];
%===============================================================================
function out = postprocessStructDisp(in)
% Return the portion of the display string to the right of the colon in the
% output of the first structure field. Input is a string.
lines = xunit.utils.stringToCellArray(in);
% Remove leading blank lines
lines = removeLeadingBlankLines(lines);
line = lines{1};
idx = find(line == ':');
out = line((idx+2):end); % struct fields display with blank space following colon
%===============================================================================
function out = removeLeadingBlankLines(in)
% Input and output are cell arrays of strings.
out = in;
while ~isempty(out) && isBlankLine(out{1})
out(1) = [];
end
%===============================================================================
function tf = isBlankLine(line)
% Input is a string.
tf = all(isspace(line));
function result = compareFloats(varargin)
%compareFloats Compare floating-point arrays using tolerance.
% result = compareFloats(A, B, compare_type, tol_type, tol, floor_tol)
% compares the floating-point arrays A and B using a tolerance. compare_type
% is either 'elementwise' or 'vector'. tol_type is either 'relative' or
% 'absolute'. tol and floor_tol are the scalar tolerance values.
%
% There are four different tolerance tests used, depending on the comparison
% type and the tolerance type:
%
% 1. Comparison type: 'elementwise' Tolerance type: 'relative'
%
% all( abs(A(:) - B(:)) <= tol * max(abs(A(:)), abs(B(:))) + floor_tol )
%
% 2. Comparison type: 'elementwise' Tolerance type: 'absolute'
%
% all( abs(A(:) - B(:) <= tol )
%
% 3. Comparison type: 'vector' Tolerance type: 'relative'
%
% norm(A(:) - B(:) <= tol * max(norm(A(:)), norm(B(:))) + floor_tol
%
% 4. Comparison type: 'vector' Tolerance type: 'absolute'
%
% norm(A(:) - B(:)) <= tol
%
% Note that floor_tol is not used when the tolerance type is 'absolute'.
%
% compare_type, tol_type, tol, and floor_tol are all optional inputs. The
% default value for compare_type is 'elementwise'. The default value for
% tol_type is 'relative'. If both A and B are double, then the default value
% for tol is sqrt(eps), and the default value for floor_tol is eps. If either
% A or B is single, then the default value for tol is sqrt(eps('single')), and
% the default value for floor_tol is eps('single').
%
% If A or B is complex, then the tolerance test is applied independently to
% the real and imaginary parts.
%
% For elementwise comparisons, compareFloats returns true for two elements
% that are both NaN, or for two infinite elements that have the same sign.
% For vector comparisons, compareFloats returns false if any input elements
% are infinite or NaN.
% Steven L. Eddins
% Copyright 2008-2009 The MathWorks, Inc.
if nargin >= 3
% compare_type specified. Grab it and then use parseFloatAssertInputs to
% process the remaining input arguments.
compare_type = varargin{3};
varargin(3) = [];
if isempty(strcmp(compare_type, {'elementwise', 'vector'}))
error('compareFloats:unrecognizedCompareType', ...
'COMPARE_TYPE must be ''elementwise'' or ''vector''.');
end
else
compare_type = 'elementwise';
end
params = xunit.utils.parseFloatAssertInputs(varargin{:});
A = params.A(:);
B = params.B(:);
switch compare_type
case 'elementwise'
magFcn = @abs;
case 'vector'
magFcn = @norm;
otherwise
error('compareFloats:unrecognizedCompareType', ...
'COMPARE_TYPE must be ''elementwise'' or ''vector''.');
end
switch params.ToleranceType
case 'relative'
coreCompareFcn = @(A, B) magFcn(A - B) <= ...
params.Tolerance * max(magFcn(A), magFcn(B)) + ...
params.FloorTolerance;
case 'absolute'
coreCompareFcn = @(A, B) magFcn(A - B) <= params.Tolerance;
otherwise
error('compareFloats:unrecognizedToleranceType', ...
'TOL_TYPE must be ''relative'' or ''absolute''.');
end
if strcmp(compare_type, 'elementwise')
compareFcn = @(A, B) ( coreCompareFcn(A, B) | bothNaN(A, B) | sameSignInfs(A, B) ) & ...
~oppositeSignInfs(A, B) & ...
~finiteAndInfinite(A, B);
else
compareFcn = @(A, B) coreCompareFcn(A, B) & ...
isfinite(magFcn(A)) & ...
isfinite(magFcn(B));
end
if isreal(A) && isreal(B)
result = compareFcn(A, B);
else
result = compareFcn(real(A), real(B)) & compareFcn(imag(A), imag(B));
end
result = all(result);
%===============================================================================
function out = bothNaN(A, B)
out = isnan(A) & isnan(B);
%===============================================================================
function out = oppositeSignInfs(A, B)
out = isinf(A) & isinf(B) & (sign(A) ~= sign(B));
%===============================================================================
function out = sameSignInfs(A, B)
out = isinf(A) & isinf(B) & (sign(A) == sign(B));
%===============================================================================
function out = finiteAndInfinite(A, B)
out = xor(isinf(A), isinf(B));
function msg = comparisonMessage(user_message, assertion_message, A, B)
%comparisonMessage Generate assertion message when comparing two arrays.
% msg = comparisonMessage(user_message, assertion_message, A, B) returns a
% string appropriate to use in a call to throw inside an assertion function
% that compares two arrays A and B.
%
% The string returned has the following form:
%
% <user_message>
% <assertion_message>
%
% First input:
% <string representation of value of A>
%
% Second input:
% <string representation of value of B>
%
% user_message can be the empty string, '', in which case user_message is
% skipped.
% Steven L. Eddins
% Copyright 2009 The MathWorks, Inc.
msg = sprintf('%s\n\n%s\n%s\n\n%s\n%s', ...
assertion_message, ...
'First input:', ...
xunit.utils.arrayToString(A), ...
'Second input:', ...
xunit.utils.arrayToString(B));
if ~isempty(user_message)
msg = sprintf('%s\n%s', user_message, msg);
end
function tf = containsRegexp(str, exp)
%containsRegexp True if string contains regular expression
% TF = containsRegexp(str, exp) returns true if the string str contains the
% regular expression exp. If str is a cell array of strings, then
% containsRegexp tests each string in the cell array, returning the results in
% a logical array with the same size as str.
% Steven L. Eddins
% Copyright 2008-2009 The MathWorks, Inc.
% Convert to canonical input form: A cell array of strings.
if ~iscell(str)
str = {str};
end