Bin data into equally spaced intervals
4 ビュー (過去 30 日間)
古いコメントを表示
From an excel sheet, I would like to average the data into 24 equally spaced bins from a particular column. The bins I want to create would list the average of every 60 rows, interspered between 30 rows (i.e., mean of rows 1-60, 91-150, etc., where 61-89, 151-179, etc. are omitted). How can I program this?
New MATLAB user here and learning.
Thank you!
0 件のコメント
採用された回答
C B
2022 年 12 月 11 日
% Import data from Excel sheet
data = xlsread('data.xlsx');
% Preallocate array for binned data
binned_data = zeros(24,1);
% Loop through rows of data, calculating average for each bin
bin_size = 60; % Number of rows per bin
skip_size = 30; % Number of rows to skip between bins
num_bins = size(data,1)/(bin_size+skip_size);
for i = 1:num_bins
% Calculate start and end rows for current bin
start_row = (i-1)*(bin_size+skip_size) + 1;
end_row = start_row + bin_size - 1;
% Calculate average of data in current bin
binned_data(i) = mean(data(start_row:end_row));
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!