% make csv output

function  [] = make_output (s,Annotation,typ,tempi)

for j = 1:14
        
        data = [];
        patient = [];
        x = [];
        smooth = [];
        der_data = [];
        
        
        patient = s (:,j);
       
        x = 1:length(patient);
        smooth = csaps(x,patient,0.25) %smoothing with cubic spline
        der_data = diff(patient); %1. derivation
        
               
        smooth_data=smooth.coefs (:,4);
        smooth_data(end+1)= patient(end);
        der_data(end+1)=der_data(end);
        der_data=der_data';
       

        smooth_data = smooth_data';
        der_data = der_data';
        
        data = table;
        data{:,1} = x';
        data{:,2} = Annotation;
        data{:,3} = patient;
        data{:,4} = smooth_data';
        data{:,5} = der_data;
        
        data.Properties.VariableNames = {'index','annotation' 'signal' 'smooth' 'derivation'};
        
        
        tempj = int2str(j);
        name = ['FNKV_data_',typ,'_',tempi,'_',tempj,'.csv']
                
        writetable(data,name,'Delimiter',';')
        clear data
        
end
    
end