How to find average of every 1024th row in a vector of 61441 rows? The result should be a 60 x 1 matrix.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
%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 Commenti
Risposte (2)
Venkat Siddarth
il 5 Mag 2023
Modificato: Venkat Siddarth
il 5 Mag 2023
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 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!