Calculating mean of different ranges in a Table

1 Ansicht (letzte 30 Tage)
Tim Podlogar
Tim Podlogar am 26 Dez. 2020
Bearbeitet: Ameer Hamza am 26 Dez. 2020
Let's say I have a table with n rows and z columns. Columns represent different variables and rows each time point. Now I would like to calculate a mean for each variable over specific ranges of n (e.g. continuously for rows 1:300:end). Could you please help? I am kind of lost...

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 26 Dez. 2020
Bearbeitet: Ameer Hamza am 26 Dez. 2020
There are several ways to do this in MATLAB. Following shows one option
M = rand(900, 10);
C = mat2cell(M, 300*ones(size(M,1)/300,1), size(M,2));
M_mean = cell2mat(cellfun(@mean, C, 'uni', 0));
or this
M_mean = squeeze(mean(reshape(M, 300, size(M,1)/300, [])))

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by