MATLAB Answers

Run statistical tests on multiple csvs

2 ビュー (過去 30 日間)
Ross Thompson
Ross Thompson 2021 年 4 月 20 日
コメント済み: Ross Thompson 2021 年 4 月 20 日
I have lots of days worth of heartrate data stored in seperate csvs and im currently running a ttest on the data 3hrs before and after 12am. I was going to run this manually on all 30 differenent days but i was wondering if there was a way of looping through all the different days to return all the p values at once.
  1 件のコメント
Rik
Rik 2021 年 4 月 20 日
That seems very likely. Once you create file list (e.g. with dir) you should be able to do the processing in a loop.
Do you have a specific question about implementing this?

サインインしてコメントする。

回答 (1 件)

Manash Sahoo
Manash Sahoo 2021 年 4 月 20 日
編集済み: Manash Sahoo 2021 年 4 月 20 日
Store your data in a folder, and use the "Dir" command to return the filenames and loop through them.
For example:
% Load your heart rate data. You can get the names of files and folders
% using the "dir" command.
files = dir(strcat(filepath,"\*.csv")) % Filepath would be the path where your csvs are located.
pval = {};
for i = 1:length(files)
HRDat = readmatrix(files.name); % You may need to edit this per your filepath.
% Do your analysis here, and return your pvalue to pval{i}.
end
Your pvalues in the cell array "pval" will thus correspond to the files in the struct array "files.name". This is usually the way I do things with heart rate data. Let me know if you have any further questions!
EDIT: Fixed the code.
MS
  7 件のコメント
Ross Thompson
Ross Thompson 2021 年 4 月 20 日
Silly me! Thanks

サインインしてコメントする。

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by