forked from OpenPIV/openpiv-matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestFindSecondPeak.m
39 lines (25 loc) · 949 Bytes
/
testFindSecondPeak.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function testFindSecondPeak
%testFindPeak Unit test for find_peak in 2D matrix
c = peaks(32);
[~,pixi,pixj] = find_peak(c);
[second_peak,pixi2,pixj2] = find_second_peak(c,pixi,pixj);
if abs(second_peak - 6.8019) > 1e-4
error('testFindPeak:notEqual', 'Incorrect output for peak.');
end
if ~isequal(pixi2, 25)
error('testFindPeak:notEqual', 'Incorrect output for pixi.');
end
if ~isequal(pixj2, 8)
error('testFindPeak:notEqual', 'Incorrect output for pixj.');
end
[~,pixi,pixj] = find_peak(ones(32));
if ~isnan(pixi) || ~isnan(pixj)
[second_peak,pixi2,pixj2] = find_second_peak(ones(32),pixi,pixj);
if abs(second_peak - 0) > 1e-4
error('testFindPeak:notEqual', 'Incorrect output for peak.');
elseif ~isequal(pixi2, 1)
error('testFindPeak:notEqual', 'Incorrect output for pixi.');
elseif ~isequal(pixj2, 1 )
error('testFindPeak:notEqual', 'Incorrect output for pixj.');
end
end