Filter löschen
Filter löschen

Mean of elements of a vector

1 Ansicht (letzte 30 Tage)
Sean O'Donnell
Sean O'Donnell am 27 Mär. 2019
Kommentiert: Sean O'Donnell am 28 Mär. 2019
I have a vector K = [1.7135 3.2725 4.0000 3.2725 1.7135 0.4775 0.0365 0 0.0365 0.4775]. How do I take the mean of all of the sets of two sequential elements of this vector without using a "for" loop? Example: Mean of K(1) and K(2), K(2) and K(3), K(3) and K(4) etc. And then put all of those individual means into a single vector?
Thanks.
  2 Kommentare
Walter Roberson
Walter Roberson am 27 Mär. 2019
Sounds like homework.
Hint: A(1:end-1) and A(2:end)
Sean O'Donnell
Sean O'Donnell am 28 Mär. 2019
This worked. Thank you!

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Rik
Rik am 27 Mär. 2019
Use a convolution.
conv(data,[0.5 0.5])
should be a good start.

Community Treasure Hunt

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

Start Hunting!

Translated by