padNaN.m 488 B

12345678910111213141516171819
  1. function data=padNaN(data)
  2. % Creates a padded data matrix from input structural array of spike times
  3. % pads with NaN
  4. % Usage: data=padNaN(data)
  5. % Input:
  6. % data : structural array of spike times
  7. % Output:
  8. % data : data matrix (zero padded)
  9. NC=length(data);
  10. fnames=fieldnames(data);
  11. for c=1:NC;
  12. eval(['Nsp(c)=length(data(c).' fnames{1} ');']);
  13. end;
  14. dtmp(1:max(Nsp),1:NC)=NaN;
  15. for c=1:NC;
  16. eval(['f=data(c).' fnames{1} ';'])
  17. dtmp(1:Nsp(c),c)=f;
  18. end;
  19. data=dtmp;