~ubuntu-branches/debian/sid/octave-tisean/sid

« back to all changes in this revision

Viewing changes to tests/extrema/test_extrema.m

  • Committer: Package Import Robot
  • Author(s): Rafael Laboissiere
  • Date: 2017-08-14 12:53:47 UTC
  • Revision ID: package-import@ubuntu.com-20170814125347-ju5owr4dggr53a2n
Tags: upstream-0.2.3
ImportĀ upstreamĀ versionĀ 0.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# This test compares the results of TISEAN extrema function
 
2
# $ extrema amplitude.dat -o "amplitude_tisean_max.dat"
 
3
# $ extrema amplitude.dat -z -o "amplitude_tisean_min.dat"
 
4
 
 
5
 
 
6
pkg load signal
 
7
close all
 
8
 
 
9
dataset = {"amplitude"};
 
10
ndata   = numel (dataset);
 
11
 
 
12
tisean_max_output = @(x) sprintf("%s_tisean_max.dat",x);
 
13
tisean_min_output = @(x) sprintf("%s_tisean_min.dat",x);
 
14
 
 
15
for i=1:ndata
 
16
 
 
17
  # Load tisean results
 
18
  data_tisean_max = load (tisean_max_output (dataset{i}));
 
19
  data_tisean_min = load (tisean_min_output (dataset{i}));
 
20
  
 
21
  data = load ([dataset{i} ".dat"]);
 
22
  n    = length (data);
 
23
 
 
24
  # Change to absolute time reference
 
25
  max_rows = rows (data_tisean_max);
 
26
  for j=1:max_rows
 
27
    data_tisean_max(max_rows+1-j,2) = sum (data_tisean_max([1:max_rows+1-j],2));
 
28
  endfor
 
29
 
 
30
  min_rows = rows (data_tisean_min);
 
31
  for j=1:min_rows
 
32
    data_tisean_min(min_rows+1-j,2) = sum (data_tisean_min([1:min_rows+1-j],2));
 
33
  endfor
 
34
 
 
35
  # Calculate with Octave  
 
36
  [pks_octave, loc, extra] = findpeaks (data, "DoubleSided", "MinPeakDistance", 2);
 
37
 
 
38
  # Compare
 
39
  figure (2*i - 1)
 
40
  plot ([1:5000],data,'b', ... 
 
41
          loc, pks_octave,'ro', ...
 
42
          data_tisean_max(:,2), data_tisean_max(:,1), 'g.');
 
43
  legend ("Data", "Octave","Tisean");
 
44
  axis tight
 
45
 
 
46
  figure (2*i)
 
47
  plot ([1:5000],data,'b', ... 
 
48
          loc, pks_octave,'ro', ...
 
49
          data_tisean_min(:,2), data_tisean_min(:,1), 'g.');
 
50
  legend ("Data", "Octave","Tisean");
 
51
  axis tight
 
52
 
 
53
 
 
54
#  printf ("Difference on %s: %.3g\n", dataset{i}, ...
 
55
#                   sqrt (mean ((data_octave-data_tisean(:,2)).^2)));
 
56
  
 
57
  fflush (stdout);
 
58
 
 
59
endfor