Calculating mean of different ranges in a Table
2 次查看(过去 30 天)
显示 更早的评论
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...
0 个评论
采纳的回答
Ameer Hamza
2020-12-26
编辑:Ameer Hamza
2020-12-26
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, [])))
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!