forked from OpenPIV/openpiv-matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testFindPeak.m
41 lines (28 loc) · 1011 Bytes
/
testFindPeak.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
37
38
function testFindPeak
%testFindPeak Unit test for find_peak in 2D matrix
[peak,pixi,pixj] = find_peak(peaks(32));
if abs(peak - 7.9770) > 1e-3
error('testFindPeak:notEqual', 'Incorrect output for peak.');
end
if ~isequal(pixi, 25)
error('testFindPeak:notEqual', 'Incorrect output for pixi.');
end
if ~isequal(pixj, 16)
error('testFindPeak:notEqual', 'Incorrect output for pixj.');
end
[peak,pixi,pixj] = find_peak(ones(32));
if ~isnan(peak)
error('testFindPeak:notEqual', 'Incorrect output for peak.');
elseif ~isnan(pixi)
error('testFindPeak:notEqual', 'Incorrect output for pixi.');
elseif ~isnan(pixj)
error('testFindPeak:notEqual', 'Incorrect output for pixj.');
end
[peak,pixi,pixj] = find_peak(NaN*ones(32));
if ~isnan(peak)
error('testFindPeak:notEqual', 'Incorrect output for peak.');
elseif ~isnan(pixi)
error('testFindPeak:notEqual', 'Incorrect output for pixi.');
elseif ~isnan(pixj )
error('testFindPeak:notEqual', 'Incorrect output for pixj.');
end