Group discretized data and determine mean

3 ビュー (過去 30 日間)
Tessa Kol
Tessa Kol 2020 年 9 月 8 日
回答済み: Tessa Kol 2020 年 9 月 8 日
Dear all,
With help of the community I discretized my data, x-coordinates of particles, into bins. For every bin I want to take the mean of all the x-coordinates that are in the bin. However, as time goes by the bins will be empty since the particles will move out of the bin to another bin. Thus, I can not use the function splitapply to group and take the mean of the x-coordinates in every bin. What can be an alternative for this problem?
for i = 1:length(files)
...
% Define the range of the bins
rng_x{i} = -0.3:0.06:0.3;
% Assign the data of x-coordinate to a predefined range
disc_x{i} = discretize(expData{i,1}(:,1),rng_x{i});
...
end

採用された回答

Tessa Kol
Tessa Kol 2020 年 9 月 8 日
I found the solution myself. Here is an example for a single data file:
mean = accumarray(disc_x{1,1}(:,1), expData{1,1}(:,2),[6 1], @mean);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by