Analyzing 2 Different Time Block Arrays
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
This is slightly similar to the questions I asked earlier about comparing a "tooth" to a "box" to find where they line up. Well, instead of doing that, now I want to compare one box array to another box array. The first box array consists of 2 arrays of the same size called startA & FinishA, and second box array consists of 2 arrays of the same size called startB & FinishB . The "A" arrays need to be lined up with the "B" arrays as best as possible by finding the best offset that is added to the "B" arrays, which is, at most, 1/3 the size of box arrays "A".
Here is the code that does work when B is a "tooth" and not a box:
CPIncrement = TimeB; %reset CPIncrement to default
offset = double.empty;
percent = double.empty;
tickcount = double.empty;
tick = 0;
percentCalc = 0;
Filtersize = numel(startTimeA);
CPsize = numel(TimeB);
Offsets = combStart : 0.000001 : combFinish;
IncrementInstances = numel(Offsets);
toothCount=zeros(numel(CPIncrement), IncrementInstances);
toothColumn=1;
for b = Offsets
tic;
CPIncrement = TimeB+b;
disp(['Offset = ', num2str(b)]);
for i = 1:Filtersize
if ( any(CPIncrement >= startTimeA(i) & CPIncrement <= finishTimeA(i)) )
%see if a value of A falls within B and its life
%if it does, add a tick to be used as a percentage later
clear tmpVec;
tmpVec=CPIncrement >= NoDupFilterTime(i) & CPIncrement <= NoDupFilterLife(i);
toothCount(tmpVec==1, toothColumn) = toothCount(tmpVec == 1, toothColumn) + 1;
end
end
disp(['ticks = ', num2str(tick)]);
tick=sum(numel(find(toothCount(:,toothColumn)~=0)));
tickcount(end+1) = tick;
%tickcount = [tickcount; tick];
percentCalc = tick/CPsize*100.0;
%calculate the precentage
disp(['percent = ', num2str(percentCalc)]);
toothColumn=toothColumn+1;
offset(end+1)= b; %adds an additional element of the offset "a" to the growing vector of "offset" to be used for later comparison
%offset = [offset; b] % Legacy version, column vector format
percent(end+1)= percentCalc; %does same thing as previous line.
%percent = [percent; percentCalc] %Legacy version, column vector format
percentCalc = 0; %reset percentCalc
disp(['percent reset = ', num2str(percentCalc)]);
toc;
end
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!