%% Příloha k diplomové práci: ANALÝZA EXPERIMENTÁLNÁCH ZÁZNAMŮ, autor: Maršánová Lucie
%% VÝPOČET MORFOLOGICKÝCH PARAMETRŮ Z EG CYKLŮ
% Skript slouží pro výpočet parametrů z EG cyklů, na základě předchozího
% automatického rozměření. Skript načte signály ze všech tří svodů 
% (rozdělené na úseky jednotlivých cyklů dle předchozí detekce QRS) 
% a výsledky automatického rozměření.
% Dle toho jsou vypočteny jednotlivé parametry a uloženy do cell buněk - pod názvem: param. 
% Definice všech parametrů není uvedena, lze ji nalézt v textu k DP.

clear all;close all;clc
load('beat.mat') % načtení signálů - jednotlivých cyklů
load('delin.mat') % načtení výsledků automatického rozměření
Fs = 2000; % vzorkovací frekvence signálů
% delin=a
% definice prázdné cell buňky pro ukládání hodnot parametrů
param(1,2)={'QJ, QT, JT'};
param(1,3)={'JTamp xy'};
param(1,4)={'posQRSamp xy'};
param(1,5)={'negQRSamp xy'};
param(1,6)={'absQRSamp xy'};
param(1,7)={'ST10 xy'};
param(1,8)={'ST20 xy'};
param(1,9)={'ST30 xy'};
param(1,10)={'ST40 xy'};
param(1,11)={'ST50 xy'};
param(1,12)={'Tamp xy'};
param(1,13)={'AUCqrst xy'};
param(1,14)={'AUCqrs xy'};
param(1,15)={'AUCst-t xy'};
param(1,16)={'+AUCqrs xy'};
param(1,17)={'-AUCqrs xy'};
param(1,18)={'+/-AUCqrs xy'};   
param(1,19)={'AUCsTamp xy'};
param(1,20)={'AUCTampTend xy'};
param(1,21)={'sTamp/TampTendAUC xy'};
param(1,22)={'+AUCst-t xy'};
param(1,23)={'-AUCst-t xy'};
param(1,24)={'AUCqrstAbs xy'};
param(1,25)={'AUCqrsAbs xy'};
param(1,26)={'AUCst-tAbs xy'};
param(1,27)={'AUCsTampAbs xy'};
param(1,28)={'AUCTampTendAbs xy'};
param(1,29)={'AUCqrsAbsRel xy'};
param(1,30)={'AUCst-tAbsRel xy'};
param(1,31)={'+AUCqrsAbsRel xy'};
param(1,32)={'-AUCqrsAbsRel xy'};
param(1,33)={'+AUCqrsAbsRelqrs xy'};
param(1,34)={'-AUCqrsAbsRelqrs xy'};
param(1,35)={'AUCsTampAbsRel xy'};
param(1,36)={'AUCTampTendAbsRel xy'};
param(1,37)={'+AUCst-tAbsRel xy'};
param(1,38)={'-AUCst-tAbsRel xy'};
param(1,39)={'CEAst-t beta'}; 
param(1,40)={'CEA lengths'}; 

%% výpočet parametrů 
  for i_phase=1  % pro každou fázi
        i_phase
         % intervaly
        QT = [];
        QJ = [];
        JT = [];
        sf = delin{i_phase,2}; sf(:,2)=[]; sf = round(sf);
        qj = sf(:,2)-sf(:,1); % QJ interval
        qt = sf(:,3)-sf(:,1); % QT interval
        jt = sf(:,3)-sf(:,2); % JT interval
        p = [qj qt jt];
        ps = round((p*1000)./Fs); 
        param(i_phase+1,2) = {ps}; % uložení do buňky

        % amplitudy
        eg1 = beat{i_phase,2};
        eg2 = beat{i_phase,3}; 
        eg3 = beat{i_phase,4}; 
        qrsMaxp_1=[];qrsMaxp_2=[];qrsMaxp_3=[];
        for i=1:size(eg1,2)
            mqrsp1=max(eg1(sf(i,1):sf(i,2),i));mqrsp1=mqrsp1(1); if mqrsp1<0; mqrsp1=0;end;
            mqrsp2=max(eg2(sf(i,1):sf(i,2),i));mqrsp2=mqrsp2(1); if mqrsp2<0; mqrsp2=0;end;
            mqrsp3=max(eg3(sf(i,1):sf(i,2),i));mqrsp3=mqrsp3(1); if mqrsp3<0; mqrsp3=0;end;
            qrsMaxp_1(i) = round(mqrsp1*1000); % v mV
            qrsMaxp_2(i) = round(mqrsp2*1000); % v mV
            qrsMaxp_3(i) = round(mqrsp3*1000); % v mV
        end
        qrsMaxp = [qrsMaxp_1' qrsMaxp_2' qrsMaxp_3'];
        param(i_phase+1,4) = {qrsMaxp}; % maximum  QRS 
        
%       maximum negativního QRS
        qrsMaxn_1=[];qrsMaxn_2=[];qrsMaxn_3=[];
        for i=1:size(eg1,2)
            
            mqrsn1=min(eg1(sf(i,1):sf(i,2),i));mqrsn1=mqrsn1(1);if mqrsn1>0; mqrsn1=0;end;
            mqrsn2=min(eg2(sf(i,1):sf(i,2),i));mqrsn2=mqrsn2(1);if mqrsn2>0; mqrsn2=0;end;
            mqrsn3=min(eg3(sf(i,1):sf(i,2),i));mqrsn3=mqrsn3(1);if mqrsn3>0; mqrsn3=0;end;
            qrsMaxn_1(i) = round(mqrsn1*1000); % v mV
            qrsMaxn_2(i) = round(mqrsn2*1000); % v mV
            qrsMaxn_3(i) = round(mqrsn3*1000); % v mV
        end
        qrsMaxn = [qrsMaxn_1' qrsMaxn_2' qrsMaxn_3'];
        param(i_phase+1,5) = {qrsMaxn}; 
        
        % celkově maximální aplituda QRS (+ i - část)
        qrsMaxpn_1=[];qrsMaxpn_2=[];qrsMaxpn_3=[];
        for i=1:size(eg1,2)               
            qrs1=eg1(sf(i,1):sf(i,2),i);qrs1x = find(abs(qrs1)==max(abs(qrs1)));qrspn1(i)=qrs1x(1);qrsMaxpn_1(i) = round(qrs1(qrspn1(i))*1000); % in microvolts
            qrs2=eg2(sf(i,1):sf(i,2),i);qrs2x = find(abs(qrs2)==max(abs(qrs2)));qrspn2(i)=qrs2x(1);qrsMaxpn_2(i) = round(qrs2(qrspn2(i))*1000); % in microvolts
            qrs3=eg3(sf(i,1):sf(i,2),i);qrs3x = find(abs(qrs3)==max(abs(qrs3)));qrspn3(i)=qrs3x(1);qrsMaxpn_3(i) = round(qrs3(qrspn3(i))*1000); % in microvolts              
        end
        qrsMaxpn = [qrsMaxpn_1' qrsMaxpn_2' qrsMaxpn_3'];
        param(i_phase+1,6) = {qrsMaxpn}; % celkově maximální aplituda QRS (+ i - část)
        
        % ST10, ST20, ST30, ST40, ST50
        st10_1=[];st20_1=[];st30_1=[];st40_1=[];st50_1=[];
        st10_2=[];st20_2=[];st30_2=[];st40_2=[];st50_2=[];
        st10_3=[];st20_3=[];st30_3=[];st40_3=[];st50_3=[];
        for i=1:size(eg1,2)
            
            st10_1(i) = eg1(sf(i,2)+(10*Fs/1000),i);
            st20_1(i) = eg1(sf(i,2)+(20*Fs/1000),i);
            st30_1(i) = eg1(sf(i,2)+(30*Fs/1000),i);
            st40_1(i) = eg1(sf(i,2)+(40*Fs/1000),i);
            st50_1(i) = eg1(sf(i,2)+(50*Fs/1000),i);

            st10_2(i) = eg2(sf(i,2)+(10*Fs/1000),i);
            st20_2(i) = eg2(sf(i,2)+(20*Fs/1000),i);
            st30_2(i) = eg2(sf(i,2)+(30*Fs/1000),i);
            st40_2(i) = eg2(sf(i,2)+(40*Fs/1000),i);
            st50_2(i) = eg2(sf(i,2)+(50*Fs/1000),i);

            st10_3(i) = eg3(sf(i,2)+(10*Fs/1000),i);
            st20_3(i) = eg3(sf(i,2)+(20*Fs/1000),i);
            st30_3(i) = eg3(sf(i,2)+(30*Fs/1000),i);
            st40_3(i) = eg3(sf(i,2)+(40*Fs/1000),i);
            st50_3(i) = eg3(sf(i,2)+(50*Fs/1000),i);
        end

        st10 = [st10_1' st10_2' st10_3']; st10 = round(st10*1000); 
        st20 = [st20_1' st20_2' st20_3']; st20 = round(st20*1000); 
        st30 = [st30_1' st30_2' st30_3']; st30 = round(st30*1000);
        st40 = [st40_1' st40_2' st40_3']; st40 = round(st40*1000);
        st50 = [st50_1' st50_2' st50_3']; st50 = round(st50*1000);
        param(i_phase+1,7) = {st10}; % amplituda ST10
        param(i_phase+1,8) = {st20}; % amplituda ST20
        param(i_phase+1,9) = {st30}; % amplituda ST30
        param(i_phase+1,10) = {st40}; % amplituda ST40
        param(i_phase+1,11) = {st50}; % amplituda ST50

        % T aplituda T vlny
        e1=[];e2=[];e3=[];x1=[];x2=[];x3=[];ta1=[];ta2=[];ta3=[];
        for i=1:size(eg1,2)
            
            e1 = eg1(sf(i,2):sf(i,3),i);x1x = find(abs(e1)==max(abs(e1))); x1(i)=x1x(1); ta1(i) = round(e1(x1(i))*1000);%x1 = find(abs(e1)==repmat(max(abs(e1)),size(e1,1),1)); ta1 = round(e1(x1)*1000); % in microV
            e2 = eg2(sf(i,2):sf(i,3),i);x2x = find(abs(e2)==max(abs(e2))); x2(i)=x2x(1); ta2(i) = round(e2(x2(i))*1000);%x2 = find(abs(e2)==repmat(max(abs(e2)),size(e2,1),1)); ta2 = round(e2(x2)*1000); 
            e3 = eg3(sf(i,2):sf(i,3),i);x3x = find(abs(e3)==max(abs(e3))); x3(i)=x3x(1); ta3(i) = round(e3(x3(i))*1000);%x3 = find(abs(e3)==repmat(max(abs(e3)),size(e3,1),1)); ta3 = round(e3(x3)*1000);
        end

        ta = [ta1' ta2' ta3'];
        param(i_phase+1,12) = {ta}; % maxT - T wave amplitude - in micro volts

        % J-Tamp interval
        JTamp1=[];JTamp2=[];JTamp3=[];
        for i=1:size(eg1,2)
           JTamp1(i)=round(x1(i)*1000./Fs); % i_sig ms 
           JTamp2(i)=round(x2(i)*1000./Fs); % i_sig ms 
           JTamp3(i)=round(x3(i)*1000./Fs); % i_sig ms 
        end
        JTamp = [JTamp1' JTamp2' JTamp3'];
        param(i_phase+1,3) = {JTamp};         % length S:maxT    

        % Plochy pod křivkou (AUC)
        a1qt=[];a2qt=[];a3qt=[];a1qj=[];a2qj=[];a3qj=[];a1jt=[];a2jt=[];a3jt=[];
        for i=1:size(eg1,2)
            a1qt(i) = trapz(eg1(sf(i,1):sf(i,3),i)); 
            a2qt(i) = trapz(eg2(sf(i,1):sf(i,3),i)); 
            a3qt(i) = trapz(eg3(sf(i,1):sf(i,3),i)); 

            a1qj(i) = trapz(eg1(sf(i,1):sf(i,2),i)); 
            a2qj(i) = trapz(eg2(sf(i,1):sf(i,2),i));
            a3qj(i) = trapz(eg3(sf(i,1):sf(i,2),i));

            a1jt(i) = trapz(eg1(sf(i,2):sf(i,3),i));
            a2jt(i) = trapz(eg2(sf(i,2):sf(i,3),i)); 
            a3jt(i) = trapz(eg3(sf(i,2):sf(i,3),i));
        end
        aqt = [a1qt' a2qt' a3qt']; % AUC Q-T
        aqj = [a1qj' a2qj' a3qj']; % AUC Q-J   
        ajt = [a1jt' a2jt' a3jt']; % AUC J-T   

        qj1p=[];qj2p=[];qj3p=[];qj1n=[];qj2n=[];qj3n=[];
        for i = 1:size(eg1,2)
           qj1 = eg1(sf(i,1):sf(i,2),i); 
           qj2 = eg2(sf(i,1):sf(i,2),i);
           qj3 = eg3(sf(i,1):sf(i,2),i);
           qj1p(i) = trapz(qj1(qj1>0));
           qj2p(i) = trapz(qj2(qj2>0)); 
           qj3p(i) = trapz(qj3(qj3>0));
           qj1n(i) = trapz(qj1(qj1<0));  
           qj2n(i) = trapz(qj2(qj2<0)); 
           qj3n(i) = trapz(qj3(qj3<0));
        end
        qjp = [qj1p' qj2p' qj3p']; % positiv. AUC Q-J
        qj1n(qj1n==0)=0.0001;
        qj2n(qj2n==0)=0.0001;
        qj3n(qj3n==0)=0.0001;
        qjn = [qj1n' qj2n' qj3n']; % negativ. AUC Q-J

        a1qjratio = abs(qj1p./qj1n); 
        a2qjratio = abs(qj2p./qj2n); 
        a3qjratio = abs(qj3p./qj3n); 
        aqjratio  = [a1qjratio' a2qjratio' a3qjratio']; % poměr +/- AUC Q-J

        a1JTamp=[];a2JTamp=[];a3JTamp=[];a1TampTend=[];a2TampTend=[];a3TampTend=[];
        a1JTampAbs=[];a2JTampAbs=[];a3JTampAbs=[];a1TampTendAbs=[];a2TampTendAbs=[];a3TampTendAbs=[];
        jt1p=[];jt2p=[];jt3p=[];jt1n=[];jt2n=[];jt3n=[];
        for i =1:size(eg1,2)
            e1 = eg1(sf(i,2):sf(i,3),i);
            e2 = eg2(sf(i,2):sf(i,3),i);
            e3 = eg3(sf(i,2):sf(i,3),i);
            a1JTamp(i) = trapz(e1(1:x1(i)));      
            a2JTamp(i) = trapz(e2(1:x2(i)));      
            a3JTamp(i) = trapz(e3(1:x3(i)));
            a1TampTend(i) = trapz(e1(x1(i)+1:end)); 
            a2TampTend(i) = trapz(e2(x2(i)+1:end)); 
            a3TampTend(i) = trapz(e3(x3(i)+1:end));
            
            a1JTampAbs(i) = trapz(abs(e1(1:x1(i))));      
            a2JTampAbs(i) = trapz(abs(e2(1:x2(i))));      
            a3JTampAbs(i) = trapz(abs(e3(1:x3(i))));
            a1TampTendAbs(i) = trapz(abs(e1(x1(i)+1:end))); 
            a2TampTendAbs(i) = trapz(abs(e2(x2(i)+1:end))); 
            a3TampTendAbs(i) = trapz(abs(e3(x3(i)+1:end)));
            
            jt1p(i) = trapz(e1(e1>0)); 
            jt2p(i) = trapz(e2(e2>0));
            jt3p(i) = trapz(e3(e3>0));
            jt1n(i) = trapz(e1(e1<=0)); 
            jt2n(i) = trapz(e2(e2<=0));
            jt3n(i) = trapz(e3(e3<=0));
        end
        aJTamp    = [a1JTamp' a2JTamp' a3JTamp']; 
        a1TampTend(a1TampTend==0)=0.0001;
        a2TampTend(a2TampTend==0)=0.0001;
        a3TampTend(a3TampTend==0)=0.0001;
        aTampTend = [a1TampTend' a2TampTend' a3TampTend'];
        a1Tratio = abs(a1JTamp./a1TampTend); 
        a2Tratio = abs(a2JTamp./a2TampTend); 
        a3Tratio = abs(a3JTamp./a3TampTend); 
        aTratio  = [a1Tratio' a2Tratio' a3Tratio'];
        
        aJTampAbs    = [a1JTampAbs' a2JTampAbs' a3JTampAbs']; 
        aTampTendAbs = [a1TampTendAbs' a2TampTendAbs' a3TampTendAbs'];
        
        aJTp = [jt1p' jt2p' jt3p'];
        aJTn = [jt1n' jt2n' jt3n'];

        param(i_phase+1,13)  = {aqt};         % AUC QRST
        param(i_phase+1,14) = {aqj};          % AUC QRS
        param(i_phase+1,15) = {ajt};          % AUC ST-T
        param(i_phase+1,16) = {qjp};          % AUC positive QRS
        param(i_phase+1,17) = {qjn};          % AUC negative QRS
        param(i_phase+1,18) = {aqjratio};     % AUC ratio (+/-)QRS
        param(i_phase+1,19) = {aJTamp};       % AUC S:Tmax
        param(i_phase+1,20) = {aTampTend};    % AUC Tmax:Tend
        param(i_phase+1,21) = {aTratio};      % AUC poměr (S:Tmax/Tmax:Tend)
        param(i_phase+1,22) = {aJTp};
        param(i_phase+1,23) = {aJTn};
        
       a1qtAbs=[];a2qtAbs=[];a3qtAbs=[];a1qjAbs=[];a2qjAbs=[];a3qjAbs=[];a1jtAbs=[];a2jtAbs=[];a3jtAbs=[];
       a1qjAbsRel=[];a2qjAbsRel=[];a3qjAbsRel=[];a1jtAbsRel=[];a2jtAbsRel=[];a3jtAbsRel=[];
       qj1pAbsRel=[];qj2pAbsRel=[];qj3pAbsRel=[];qj1nAbsRel=[];qj2nAbsRel=[];qj3nAbsRel=[];
       qj1pAbsRelqj=[];qj2pAbsRelqj=[];qj3pAbsRelqj=[];qj1nAbsRelqj=[];qj2nAbsRelqj=[];qj3nAbsRelqj=[];
       a1JTampAbsRel=[];a2JTampAbsRel=[];a3JTampAbsRel=[];a1TampTendAbsRel=[];a2TampTendAbsRel=[];a3TampTendAbsRel=[];
       jt1pAbsRel=[];jt2pAbsRel=[];jt3pAbsRel=[];jt1nAbsRel=[];jt2nAbsRel=[];jt3nAbsRel=[];
        for i =1:size(eg1,2)
            a1qtAbs(i) = trapz(abs(eg1(sf(i,1):sf(i,3),i)));
            a2qtAbs(i) = trapz(abs(eg2(sf(i,1):sf(i,3),i)));
            a3qtAbs(i) = trapz(abs(eg3(sf(i,1):sf(i,3),i)));
            
            a1qjAbs(i) = trapz(abs(eg1(sf(i,1):sf(i,2),i)));
            a2qjAbs(i) = trapz(abs(eg2(sf(i,1):sf(i,2),i)));
            a3qjAbs(i) = trapz(abs(eg3(sf(i,1):sf(i,2),i)));
            
            a1jtAbs(i) = trapz(abs(eg1(sf(i,2):sf(i,3),i)));
            a2jtAbs(i) = trapz(abs(eg2(sf(i,2):sf(i,3),i)));
            a3jtAbs(i) = trapz(abs(eg3(sf(i,2):sf(i,3),i)));
            
            a1qjAbsRel(i) = a1qjAbs(i)/a1qtAbs(i);
            a2qjAbsRel(i) = a2qjAbs(i)/a2qtAbs(i);
            a3qjAbsRel(i) = a3qjAbs(i)/a3qtAbs(i);
            
            a1jtAbsRel(i) = a1jtAbs(i)/a1qtAbs(i);
            a2jtAbsRel(i) = a2jtAbs(i)/a2qtAbs(i);
            a3jtAbsRel(i) = a3jtAbs(i)/a3qtAbs(i);

            qj1pAbsRel(i) = abs(qj1p(i))/a1qtAbs(i);
            qj2pAbsRel(i) = abs(qj2p(i))/a2qtAbs(i);
            qj3pAbsRel(i) = abs(qj3p(i))/a3qtAbs(i);
            
            qj1nAbsRel(i) = abs(qj1n(i))/a1qtAbs(i);
            qj2nAbsRel(i) = abs(qj2n(i))/a2qtAbs(i);
            qj3nAbsRel(i) = abs(qj3n(i))/a3qtAbs(i);
            
            qj1pAbsRelqj(i) = abs(qj1p(i))/a1qjAbs(i);
            qj2pAbsRelqj(i) = abs(qj2p(i))/a2qjAbs(i);
            qj3pAbsRelqj(i) = abs(qj3p(i))/a3qjAbs(i);
            
            qj1nAbsRelqj(i) = abs(qj1n(i))/a1qjAbs(i);
            qj2nAbsRelqj(i) = abs(qj2n(i))/a2qjAbs(i);
            qj3nAbsRelqj(i) = abs(qj3n(i))/a3qjAbs(i);
            
            a1JTampAbsRel(i)=a1JTampAbs(i)/a1qtAbs(i);
            a2JTampAbsRel(i)=a2JTampAbs(i)/a2qtAbs(i);
            a3JTampAbsRel(i)=a3JTampAbs(i)/a3qtAbs(i);
            
            a1TampTendAbsRel(i)=a1TampTendAbs(i)/a1qtAbs(i);
            a2TampTendAbsRel(i)=a2TampTendAbs(i)/a2qtAbs(i);
            a3TampTendAbsRel(i)=a3TampTendAbs(i)/a3qtAbs(i);
            
            jt1pAbsRel(i)=abs(jt1p(i))/a1qtAbs(i);
            jt2pAbsRel(i)=abs(jt2p(i))/a2qtAbs(i);
            jt3pAbsRel(i)=abs(jt3p(i))/a3qtAbs(i);
            
            jt1nAbsRel(i)=abs(jt1n(i))/a1qtAbs(i);
            jt2nAbsRel(i)=abs(jt2n(i))/a2qtAbs(i);
            jt3nAbsRel(i)=abs(jt3n(i))/a3qtAbs(i);
            
        end
        aqtAbs = [a1qtAbs' a2qtAbs' a3qtAbs'];
        aqjAbs = [a1qjAbs' a2qjAbs' a3qjAbs'];
        ajtAbs = [a1jtAbs' a2jtAbs' a3jtAbs'];
        
        param(i_phase+1,24)={aqtAbs};
        param(i_phase+1,25)={aqjAbs};
        param(i_phase+1,26)={ajtAbs};
        param(i_phase+1,27)={aJTampAbs};
        param(i_phase+1,28)={aTampTendAbs};
        
        param(i_phase+1,29)={[a1qjAbsRel' a2qjAbsRel' a3qjAbsRel']};
        param(i_phase+1,30)={[a1jtAbsRel' a2jtAbsRel' a3jtAbsRel']};
        param(i_phase+1,31)={[qj1pAbsRel' qj2pAbsRel' qj3pAbsRel']};
        param(i_phase+1,32)={[qj1nAbsRel' qj2nAbsRel' qj3nAbsRel']};
        param(i_phase+1,33)={[qj1pAbsRelqj' qj2pAbsRelqj' qj3pAbsRelqj']};
        param(i_phase+1,34)={[qj1nAbsRelqj' qj2nAbsRelqj' qj3nAbsRelqj']};
        param(i_phase+1,35)={[a1JTampAbsRel' a2JTampAbsRel' a3JTampAbsRel']};
        param(i_phase+1,36)={[a1TampTendAbsRel' a2TampTendAbsRel' a3TampTendAbsRel']};
        param(i_phase+1,37)={[jt1pAbsRel' jt2pAbsRel' jt3pAbsRel']};
        param(i_phase+1,38)={[jt1nAbsRel' jt2nAbsRel' jt3nAbsRel']};
        
        
                
        % Uhly a délky centrální elektrické osy
        betaQJ =[]; betaJT =[]; rQJ=[]; rJT=[];
        for i = 1:size(eg1,2)
            [beta_qj, l_qj] = angCEA_2D(eg1(sf(i,1):sf(i,2),i),eg2(sf(i,1):sf(i,2),i));
            [beta_jt, l_jt] = angCEA_2D(eg1(sf(i,2):sf(i,3),i),eg2(sf(i,2):sf(i,3),i));                                 
            betaQJ    = [betaQJ beta_qj];
            betaJT    = [betaJT beta_jt];  
            rQJ    = [rQJ l_qj];
            rJT    = [rJT l_jt];
        end
        angCEA = [betaQJ' betaJT'];   
        lengthCEA = [rQJ' rJT'];        

        param(i_phase+1,39) = {angCEA};   % uhel centralni elektrické osy 
        param(i_phase+1,40) = {lengthCEA}; % CEA 
  end
  param
% clear beat delin
