Next: , Previous: , Up: Directory Index   [Contents][Index]


2.17 mathematical

Function File: intset = addToIntegerSet ( intset, ints )

Add integers to an set of integers, stored as contiguous intervals.

Arguments

intset

set of integers, stored as a Nx2 matrix of intervals:

[min1, max1; min2, max2; min3, max3; ...]
ints

integers to add to set

Examples

assert(isempty(addToIntegerSet([], [])))
assert(addToIntegerSet([], 1:4) == [1,4])
assert(addToIntegerSet([], [1:3, 5:9]) == [1,3; 5,9])
assert(addToIntegerSet([], [1, 1:5, 5, 4:8, 11]) == [1,8; 11,11])
assert(addToIntegerSet([1,4], []) == [1,4])
assert(addToIntegerSet([1,4], 1:4) == [1,4])
assert(addToIntegerSet([1,4], 6:8) == [1,4; 6,8])
assert(addToIntegerSet([1,4], [1:3, 5:9]) == [1,9])
assert(addToIntegerSet([1,4], [1, 1:5, 5, 4:8, 11]) == [1,8; 11,11])
assert(addToIntegerSet([1,3; 5,6; 8,11; 15,20], [4, 4, 13, 21]) == [1,6; 8,11; 13,13; 15,21])
Function File: freqSeries = FourierTransform ( ti, xi, oversampleby )

Computes Fourier-transform of input timeseries with timestamps {t_j} and data-points {x_j}, where j = 0 ... N-1 This function complies with the LSC convention for Fourier-transforms, i.e. xFT(f) = dt * sum_{j=0}^{N-1} x_j * e^{-2pi i f t_j}

The optional argument oversampleby specifies an INTEGER factor to oversample the FFT by, using zero-padding of the time-series.

The returned ’freqSeries’ is a struct with two array-fields:

where k = 0 ... N-1, and DFT frequency-bins f_k = k / N

Note

Matrix inputsThe input can contain several time-series data vectors xi over the same N time-samples, where each time-series is a row-vector, ie the dimension of xi must be Nseries x N, where ’Nseries’ is the number of parallel time-series.

The FFT is therefore performed along rows of xi, and the resulting x_k has the same arrangement.

Examples

f0 = 10.0;
t = 0:0.01:1;
F = FourierTransform(t, sin(2*pi*f0*t));
[~, ii] = max(abs(F.xk));
assert(abs(F.fk(ii)), f0, 0.1);
Function File: timeSeries = FourierTransformInv ( fk, xk, oversampleby )

Computes inverse Fourier-transform of input frequency-series with frequency steps fk and data-points xk. This function complies with the LSC convention for inverse Fourier-transforms, i.e. xi(t) = df * sum_{k=0}^{n-1} x_k * e^{2pi i f_k t}

The optional argument oversampleby specifies an INTEGER factor to oversample the FFT by

Examples

dt = 0.1;
ti = dt * [ 0:999 ];
xi = zeros ( size ( ti ) );
xi ( 555 ) = 1;
ft = FourierTransform ( ti, xi );
ts = FourierTransformInv ( ft.fk, ft.xk );
err = max ( abs ( ts.xi - xi ) );
assert ( err < 1e-9 );
Loadable Module: gsl

Loads the SWIG-generated module ‘gsl’.

Examples

gsl;
gsl;
assert(gsl_sf_gamma_inc(4.5, 0), gamma(4.5), 1e-3);
assert(gsl_sf_gamma_inc(4.5, 2.2), 10.273, 1e-3);
assert(gsl_sf_gamma_inc_P(4.5, 2.2), 0.11683, 1e-3);
assert(gsl_sf_gamma_inc_Q(4.5, 2.2), 1 - 0.11683, 1e-3);
Function File: octapps_md5sum ( str )

Calculate the MD5 hash value of the string str.

Examples

assert(octapps_md5sum("octapps"), "ab220839eb6a31c782f1726f1031f2d3")
Function File: X = possibilities ( x, N )

Build a matrix whos columns are all possible selections of N elements from the vector x, in the order that would be given by an N-dimensional nested loop. For example:

M = [];
for ii = possibilities(-1:1, 3);
  M = [M, ii];
endfor

will produce the same matrix M as:

M = [];
for i = -1:1
  for j = -1:1
    for k = -1:1
      M = [M, [i;j;k]];
    endfor
  endfor
endfor

except that the dimensionality N can be determine at run time

Examples

M1 = [];
for ii = possibilities(-1:1, 3);
  M1 = [M1, ii];
endfor
M2 = [];
for i = -1:1
  for j = -1:1
    for k = -1:1
      M2 = [M2, [i;j;k]];
    endfor
  endfor
endfor
assert(M1, M2);
Function File: [ y1, y2, … ] = runningFunction ( F, n, x1, x2, … )

Compute the function F over a running window of n values of each ’x’.

Arguments

F

Running window function

n

Running window size

x1
x2

Input data

y1
y2

Output data, e.g. y1 = [F(x1(1:n)), F(x1(2:n+1)), …]

Examples

assert(runningFunction(@mean, 3, 1.1:0.7:9.3), 1.8:0.7:8.1, 1e-3)
assert(runningFunction(@median, 3, 1:10), 2:9, 1e-3)
Function File: UnitsConstants

Define common units and physical constants

Examples

UnitsConstants;

Next: , Previous: , Up: Directory Index   [Contents][Index]