Thanks guys for help. With this code:
clc;
T = importdata('data_jana.xls');
result = cell(1, size(T,2));
for col = 1:size(T,2)
%// Get length-value pairs
[lengths, values] = runLengthEncode(T(:,col));
%// Compute all deltas
deltas = 0.2*lengths(values == 0.2);
%// Remove deltas following 5 zeros
idxFiveZeros = find(lengths > 4 & values == 0, 1);
if(isempty(idxFiveZeros))
idxFiveZeros = numel(lengths);
end
deltas = deltas(1:sum(values(1:idxFiveZeros) == 0.2));
%// Store result for column
result{col} = deltas;
end
There is no errors.
But the problem is that this script stop definitely the deltas calculation when he found five zeros consecutively. It is not that I want to do. One example: col1 = 0, 0, 0.2, 0.2, 0, 0, 0, 0, 0, 0.2, 0.2, 0.2, 0, 0.2, 0, 0.2; result_col1= 0.4 1.0; In this example, after the first two 0.2 there is five 0 consecutively (the rule to stop), so the script add these two values. Then, the script continue and found 0.2 spaced by less than five 0 consecutive so he add all values. Thanks.