How to binning 2-d data ?
조회 수: 23 (최근 30일)
이전 댓글 표시
I have a data of 29459*13 and I want to bin the data by taking 1500 rows means one bin will be 1500*13. Please can anyone help me out with this regard ?
Thank you for your time.
댓글 수: 4
Christopher McCausland
2021년 8월 31일
A very very low resolotion FFT maybe? However so much data will be lost that I cannot see the point of this @ARUNIMA DAS. What is the purpose of this?
Christopher
답변 (2개)
Adam Danz
2021년 8월 31일
편집: Adam Danz
2021년 8월 31일
This approach uses repelem() to generate group IDs by rows.
data is the input matrix.
nRows specifies the number of consecutive rows for each bin (=1500)
binID is the bin ID numbers for each row of data. (1;1;1;....(1500 1s); 2;2;2;...;etc). The last group will have less than 1500 rows since the height of your matrix is not divisible by 1500.
% Create demo data
rng('default')
data = rand(29459,13);
% Specify number of rows per bin
nRows = 1500;
% Create bin IDs
nGroups = ceil(size(data,1)/nRows);
binID = repelem((1:nGroups)', nRows, 1);
binID(size(data,1)+1:end) = [];
Data from bin n is isolated by,
data(binID==n, :)
Compute the average of all data within columns of each bin.
binAvg will be a 20x13 matrix for 20 groups and 13 columns.
binAvg = groupsummary(data, binID(:), 'mean')
Confirm results by selecting a bin and comparing its average with the results above
testBin = 8;
testBinAvg = mean(data(binID==testBin,:));
isequal(testBinAvg, binAvg(testBin,:))
Compute the average of all data combined within each bin
binAvgAll will be 20x1 for 20 groups.
binAvgAll = arrayfun(@(g)mean(data(binID==g,:),'all'), unique(binID))
Confirm results by selecting a bin and comparing its average with the results above
testBin = 14;
testBinAvg = mean(data(binID==testBin,:),'all');
isequal(testBinAvg, binAvgAll(testBin))
댓글 수: 0
Walter Roberson
2021년 9월 1일
You will have to decide how you want to handle the last partial bin that is only 959 rows instead of 1500.
You can return a row vector of the extracted features, and the result would be put together into a 20 x whatever array of features. Which you would transpose or not transpose depending on which classification routine you use.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!