Average of the Vector elements in the matrix
Ältere Kommentare anzeigen
I have a matrix of 815*440 and I need to take the average of every 20 elements in all the rows and find the output as 815*22
Any help is appreciated
Thanks
3 Kommentare
Kirby Fears
am 16 Sep. 2015
Bearbeitet: Kirby Fears
am 16 Sep. 2015
Trying to understand your questions: are you trying to compute the mean of columns 1, 21, 41,..., 421 for each row, then repeat this exercise for columns 2, 22, ... , 422, and keep repeating until you have a 815 x 22 matrix of such means? This would actually give an 815 x 20 matrix...
Are you instead trying to take the average of columns 1,2,...,20 for each row, and repeat for columns 21,22,...,40, etc until you get to the mean of columns 421,422,...,440? This would give an 815 x 22 output as you mentioned.
Jab
am 16 Sep. 2015
Kirby Fears
am 16 Sep. 2015
Bearbeitet: Kirby Fears
am 16 Sep. 2015
The answer I posted below solves that problem. Please give it a try.
Akzeptierte Antwort
Weitere Antworten (1)
James Tursa
am 16 Sep. 2015
Bearbeitet: James Tursa
am 16 Sep. 2015
Assuming you are averaging every 20 elements, not a sliding window:
A = your 815 x 440 matrix
m = mean(reshape(A',20,[]));
Anew = reshape(m,22,[])';
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!