LoadCSVsAsMatrix.m 825 B

12345678910111213141516171819202122
  1. function out=LoadCSVsAsMatrix(mousePathdir, csvs)
  2. % Load all csvs in a matrix. The resulting matrix is N x F x C
  3. % with N being the number of subjects (ie. the number of csvs),
  4. % F being the number of frames (ie. each csv's number of rows),
  5. % C is the number of columns
  6. % Parameters:
  7. % - mousePathdir (string): the path of the mouse subject
  8. % - csvs: the list of csvs without any parent folder to load in our final matrix
  9. % First, we need to know how big any of these matrices are
  10. testMatrix = readmatrix(fullfile(mousePathdir, csvs{1}));
  11. [frames, columns] = size(testMatrix);
  12. out = zeros(1, frames, columns);
  13. for i=1:length(csvs)
  14. csv = csvs{i};
  15. matrix = readmatrix(fullfile(mousePathdir, csv));
  16. out(i, :, :) = matrix(1:frames, :);
  17. end
  18. end