TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
rs.m
Go to the documentation of this file.
1 function [y1]=rs(y1,T,f2)
2 % [y2] = rs(y1, T) resamples y1 to the target sampling rate y2 using T
3 % [y2] = rs(y1, f1, f2) resamples y1 with f1 to the target sampling rate f2
4 %
5 % RS does not require overlap data.
6 %
7 % see also: SOPEN, SREAD, SCLOSE, MAT2SEL, SAVE2TXT, SAVE2BKR
8 %
9 % Reference(s):
10 
11 % $Revision: 1.2 $
12 % $Id: rs.m 2202 2009-10-27 12:06:45Z schloegl $
13 % Copyright (C) 1997-2004 by Alois Schloegl
14 % a.schloegl@ieee.org
15 % This is part of the BIOSIG-toolbox http://biosig.sf.net/
16 
17 % This library is free software; you can redistribute it and/or
18 % modify it under the terms of the GNU Library General Public
19 % License as published by the Free Software Foundation; either
20 % Version 2 of the License, or (at your option) any later version.
21 %
22 % This library is distributed in the hope that it will be useful,
23 % but WITHOUT ANY WARRANTY; without even the implied warranty of
24 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 % Library General Public License for more details.
26 %
27 % You should have received a copy of the GNU Library General Public
28 % License along with this library; if not, write to the
29 % Free Software Foundation, Inc., 59 Temple Place - Suite 330,
30 % Boston, MA 02111-1307, USA.
31 
32 if nargin==3,
33  f1=T;
34  if f1==f2
35  return;
36  elseif f1>f2
37  D=f1/f2;
38  [yr,yc]=size(y1);
39  LEN=yr/D;
40  y2=zeros(yr*f2/f1,yc);
41  for k=0:LEN-1
42  y2(k+1,:)=sum(y1(k*D+(1:D),:),1)/D;
43  end;
44  y1=y2;
45  else %f1<f2
46  y1=y1(ceil((1:size(y1,1)*f2/f1)/f2*f1),:);
47  end;
48 
49 elseif nargin==2,
50  [f1,f2]=size(T);
51  if f1==f2,
52  return;
53  end;
54  [yr,yc]=size(y1);
55  LEN=yr/f1;
56  y2=zeros(yr*f2/f1,yc);
57  for k=0:LEN-1
58  y2(k*f2+(1:f2),:)=T'*y1(k*f1+(1:f1),:);
59  end;
60  y1=y2;
61 end;
rs
function rs(in y1, in T, in f2)