reshaping multiple data sets

1 回表示 (過去 30 日間)
C.G.
C.G. 2021 年 10 月 6 日
回答済み: Voss 2021 年 10 月 6 日
I have a 50x4 double. I want to reshape each column of the matrix by taking the mean of every 10 elements.
I have tried writing a loop to do this but it only writes the last iteration. I have tried indexing into this but I get the error:
Brace indexing is not supported for variables of this type.
for a = 1:4;
Out = mean(reshape(vel{a}(1:50),10,[]),1);
end

回答 (1 件)

Voss
Voss 2021 年 10 月 6 日
The error happens because vel is not a cell array.
To keep the result from each iteration of the loop, you can make Out a matrix and store the result in each column of Out:
Out = zeros(size(vel,1)/10,4);
for a = 1:4
Out(:,a) = mean(reshape(vel(:,a),10,[]),1).';
end

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by