function [ file_array, number_of_files ] = coherence_counter( input_path )
%UNTITLED1 Summary of this function goes here
%   Detailed explanation goes here

files=dir([input_path,'A','*.mat']);    % search for *.mat files which starts with A
number_of_files=length(files);

count_while1=1;
count_while2=1;
count_files=0;
epoche=true;

file_array=cell(number_of_files,1); % storage of the filepaths

while(count_files~=number_of_files) % exit condition: if counter=number of existing mat-files!
        while(epoche==true)    % epoche is a control variable!!!
            filename=sprintf('A%dE%d.mat',count_while1,count_while2);   % creates the filename, which will be used for the exist-check
            current_file=[input_path,filename]; % constructs the filepath
            if(exist(current_file)~=0) % file exists  :-)
%                 current_file=['C:\temp\Patients\mat-Files\test\',filename];
%                 fprintf('Res: %s\n',current_file);
                count_files=count_files+1;  % file found counter++
                file_array(count_files)=cellstr(current_file); % storage into a cell-array
                epoche=true;
            else
                epoche=false;
            end
            count_while2=count_while2+1;    % counter for E
        end
        count_while1=count_while1+1;        % counter for A
        count_while2=1;                     % next 'Abschnitt'
        epoche=true;
end

end
