function [abshfgktmat]=calcabshfgktmat(gradientcell,signallaenge,zaehlmat,anzahlelemente)
%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION.                                                                      

%--------------------------------------------------------------
totsum=[];
for h=1:size(gradientcell,1)
    totsum(h)=sum(gradientcell{h});
end
totsumid=sum(totsum(1)==totsum);
if totsumid~=size(gradientcell,1)
    errordlg('Mismatch zwischen Signallaenge und Stimulianzahl pro Faktor!','Fehler!');
    return
end
for d=1:length(gradientcell)
stimulianzahlmat=gradientcell{d};
verhaeltniscell{d}=stimulianzahlmat./signallaenge;
end
index=[];
abshfgktmat=zeros(size(zaehlmat));
relhfgktmat=zeros(size(zaehlmat));
dimensionen=size(relhfgktmat);
indicesstring='';
for z=1:length(dimensionen)
    indicesstring=[indicesstring,'index(',num2str(z),'),'] ;  
end
indicesstring(length(indicesstring))=[];
for k=1:anzahlelemente
eval(['[',indicesstring,']=ind2sub(size(zaehlmat),find(zaehlmat==k))',';'])
subindstring='';
for u=1:size(gradientcell,1) 
sizevar=1;
for t=1:u
    sizevar=sizevar*size(zaehlmat,t);
end
subindstring=[subindstring,num2str(verhaeltniscell{u}(index(u))),'*'];
end
subindstring(length(subindstring))=[];
eval(['abshfgktmat(',indicesstring,')=signallaenge*',subindstring,';']);
end
if int16(sum(sum(abs(abshfgktmat-round(abshfgktmat)))))>1
    errordlg('Absolute Häufigkeit mindestens einer Zelle ist dezimal! Vorgang wird abgebrochen!','Achtung:');
    abshfgktmat=[];
    return
end

abshfgktmat=round(abshfgktmat);

return