extractdatac.m 700 B

1234567891011121314151617181920212223
  1. function data=extractdatac(data,Fs,t)
  2. % Extract segements of continuous data between t(1) and t(2)
  3. % Usage: data=extractdatac(data,Fs,t)
  4. %
  5. % Input:
  6. % data: continous data in the form samples x channels or a single vector
  7. % Fs: sampling frequency
  8. % t : time as a 2d vector [t(1) t(2)]
  9. % Note that sampling frequency and t have to be in consistent units
  10. % Output:
  11. % data: data between t(1) and t(2)
  12. if nargin < 3;
  13. error('need all three arguments');
  14. end;
  15. if t(1) < 0 || t(2)<=t(1);
  16. error('times cannot be negative and t(2) has to greater than t(1)');
  17. end;
  18. data=change_row_to_column(data);
  19. N=size(data,1);
  20. tt=(0:N-1)/Fs;
  21. indx=find(tt>=t(1) & tt<t(2));
  22. data=data(indx,:);