How to find average of every 1024th row in a vector of 61441 rows? The result should be a 60 x 1 matrix.
조회 수: 2 (최근 30일)
이전 댓글 표시
%The Vector name is fx. I want to convert a 61441 x 1 matrix to 60 x 1 matrix such that each value in new matrix is average of 1024 rows in original matrix.
댓글 수: 0
답변 (2개)
Venkat Siddarth
2023년 5월 5일
편집: Venkat Siddarth
2023년 5월 5일
From the context,I understand that you want to convert a 61441x1 matrix to 60x1 matrix,such that each value is a mean of 1024 rows,here assuming that number of elements is 61440 but not 61441 since it is not a multiple of 1024 ,this can be solved as follows:
% create a sample 61440 x 1 matrix
fx = rand(61440, 1);
size(fx)
% reshape the matrix into a 1024 x 60 x 1 matrix
fx_reshape = reshape(fx, 1024, 60, []);
size(fx_reshape)
% take the mean of each 1024 x 60 slice along the first dimension
fx_mean = mean(fx_reshape, 1);
size(fx_mean)
% reshape the resulting 1 x 60 x 1 matrix into a 60 x 1 matrix
fx_final = reshape(fx_mean, [], 1);
size(fx_final)
I hope this resolves your query,
Regards
Venkat Siddarth V
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!