function [matrix_signal,data] = jansen_superposition_partI(measuredsignal)
% jansen_superposition_partI exactly divides Jansen's signal according to
% its repetition%
%% Syntax
%
% [matrix_signal,data] = jansen_superposition_partI(measuredsignal)
%
%% Description
%
% Jansen's signals are divided into their repetition because of analysis of
% linear relationship between inputs and outputs. Every repetition of Jansen's signals enters 
% to the next step of that analysis. One repetition contains two inputs and two outputs.
%
%% Input
%
% measured signal: Jansen's signal from the sponge experiments in the form
%                  of .hdf5 format
%
%% Output
%
% matrix signal: a 4-by-n matrix contains one repetition of Jansen's
%                signal, the first two rows represent two inputs, the next two rows
%                represent two outputs
%
% data: an iddata object contains one repetition of Jansen signal, that
%       object includes two inputs and only one output, that data object is
%       estimated for each output of  Jansen's signal separately
%
%% Author: Veronika Svozilová
%% Date: 15.7.2015
%
%% Jansen signals from sponge experiments with their begginings
% sponge_C1_S1_Jansen1_2015.06.16_11.11.27.hdf5 = [16300, 73490, 130800, 187900, 245100];
% sponge_C1_S2_Jansen1_2015.06.16_11.38.46.hdf5 = [21130, 77780, 135100, 193200, 250300];
% sponge_C1_S1_Jansen2_2015.06.16_11.12.52.hdf5 = [27460, 84460, 141300, 198700, 255500];
% sponge_C1_S2_Jansen2_2015.06.16_11.40.12.hdf5 = [36710, 93580, 150500, 209400, 266300];
%
measuredsignal = 'sponge_C1_S1_Jansen1_2015.06.16_11.11.27.hdf5';
infoorigsignal = h5info(measuredsignal);
origin = h5read(measuredsignal, '/RawData/Samples');
fs = 4800;

start = [16300, 73490, 130800, 187900, 245100];
difference = 47110;

for l = 1:4;
    for k = 1:length(start)
        ending(k) = start(k) + difference;
        signal{l,k} = double(origin(l,start(k):ending(k)));
    end
end

matrix_signal = zeros(4,difference+1);
for p = 1:4
    matrix_signal(p,:) = signal{p,1};
end
data = iddata(matrix_signal(3,:)',matrix_signal(1:2,:)',1/4800);
end
