fileName = 'exp1800_1800rpm_f';

% old experiments
% fileName = 'exp247_500rpm';
% fileName = 'exp245_750rpm2';
% fileName = 'exp244_1000rpm';
% fileName = 'exp243_1000rpm2'; % do NOT use
timeIndex = 15;

load(['serverData' filesep fileName '.mat']);

diffTime = myData(timeIndex,2:end)-myData(timeIndex,1:end-1);
diffIndex = [1; find(diffTime>300)'; length(myData)];
   
numberOfSteps = length(diffIndex)-1;
timeGrid = zeros(1,numberOfSteps);
lambda_mean = zeros(1,numberOfSteps);
meanwidth_mean = zeros(1,numberOfSteps);
   
for i=1:numberOfSteps
    timeResult(i).lambda = myData(1,diffIndex(i):diffIndex(i+1));
    timeResult(i).meanWidth = myData(2,diffIndex(i):diffIndex(i+1));
    timeResult(i).convexity = myData(3,diffIndex(i):diffIndex(i+1));
    timeResult(i).roughnessH = myData(4,diffIndex(i):diffIndex(i+1));
    timeResult(i).roughnessM = myData(5,diffIndex(i):diffIndex(i+1));
    timeResult(i).roughness = myData(6,diffIndex(i):diffIndex(i+1));
    timeResult(i).lambdaH = myData(7,diffIndex(i):diffIndex(i+1));
    timeResult(i).lambdaM = myData(8,diffIndex(i):diffIndex(i+1));
    timeResult(i).sphericity = myData(9,diffIndex(i):diffIndex(i+1));
    timeResult(i).sphericity2 = myData(10,diffIndex(i):diffIndex(i+1));
    timeResult(i).brightFactorH = myData(11,diffIndex(i):diffIndex(i+1));
    timeResult(i).brightFactorM = myData(12,diffIndex(i):diffIndex(i+1));
%     timeResult(i).brightFactorM = myData(13,diffIndex(i):diffIndex(i+1));
%     timeResult(i).brightFactorM = myData(13,diffIndex(i):diffIndex(i+1));
%     lambda_meanh(i) = mean(timeResult(i).lambdaH);
%     meanwidth_meanh(i) = mean(timeResult(i).meanwidthH);
%     lambda_meanm(i) = mean(timeResult(i).lambdaM);
%     meanwidth_meanm(i) = mean(timeResult(i).meanwidthM);
    timeGrid(i) = round(mean(myData(timeIndex,diffIndex(i):diffIndex(i+1)))/60);
end

save(['localData' filesep fileName '_resultStruct.mat'], ...
    'timeResult', 'timeGrid');