Load in subsets of data from csv file based on multiple column values
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a csv file for which I need to load in timeseries of data for each member of a pair. The file contains data for activity windows 1 - 6 and for multiple pairs. Each pair is made up of subject (sub) 1 and subject (sub) 2, and contains data for windows 1 through 6.
For each window, I need to load in the data for pair 1 subject 1 and pair 1 subject 2 together. The timeseries are the same length within the same pair, but are different across pairs (from the 'alpha' column). Thus, to use pair 1 window 1 as an example, I need two timeseries: (1) The alpha timeseries corresponding to P01, W1, sub 1 and (2) alpha timeseries corresponding to P01, W1, sub 2
I then need to compute cross correlation on those two timeseries, from which I will extract the max correlation value and the corresponding lag, as well as the correlation value at 0 lag and I can just append these results to a csv file ( I already have code working to do the cross correlation stuff, I just need to figure out how to loop through and load the two appropriate timeseries together).
I am trying to use 'readTable' and 'varfun' to filter the data and apply the function but I am struggling to figure out how to load in the two timeseries together, and then load the two for the next window, etc.. then repeat again for the next pair.
I've attached a preview of the data.
Thank you
댓글 수: 1
Bob Thompson
2018년 5월 7일
What about using csvread()? I know it doesn't organize things as prettily as readTable, but sorting through the data just becomes a matter of indexing at that point.
(I did not look at your attached file, sorry, so it may be evident from that file that my question means nothing.)
채택된 답변
Ameer Hamza
2018년 5월 7일
The following lines will split the dataset such that each separated table have same pair, window values and both values for subject,
data = readtable('example.csv');
dataSplit = splitapply(@(x) {cell2table(x, 'VariableNames', data.Properties.VariableNames)}, table2cell(data), findgroups(data(:,[1,4])));
The result is a cell array. Access each separated elements using cell indexing like this: dataSplit{1}, dataSplit{2}, ...
댓글 수: 2
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!