
display("functions")

function win = window(vec, pos)
  pos = pos / 10;
  win = vec(pos-50:pos+50-1,:);
end

function flat = flatten(win)
  flat = reshape(win, rows(win)*columns(win), 1);
end

# extract several (windowed) samples from the given input vector
function wins = getSamples(Gyro, Accel, Magnet, start, percent)
  wins = {};
  lengthMS = length(Magnet) * 10;
  pEnd = lengthMS * percent;
  for i = start:150:pEnd
    winGyro = window(Gyro, i);
    winAccel = window(Accel, i);
    winMagnet = window(Magnet, i);
    win = [winGyro winAccel];
    win = flatten(win);
    wins = [wins win];
  end
end