Filter löschen
Filter löschen

Code running multiple times for different elements of a matrix

2 Ansichten (letzte 30 Tage)
Andreas S
Andreas S am 9 Okt. 2020
Kommentiert: Matt J am 10 Okt. 2020
Hi everyone. I need some help to code this problem:
The data is 480x10 matrix(ret). I want to calculate the mean of each column from the past 120 elements of the same column
m1=mean(ret(1:120,1:10))
m2=mean(ret(2:121,1:10))
...
m360=mean(ret(360:480,1:10))
How can i do it with a loop and receive the results in a matrix 360x10.

Akzeptierte Antwort

Matt J
Matt J am 9 Okt. 2020
Bearbeitet: Matt J am 9 Okt. 2020
m=conv2(ret,ones(120,1)/120,'valid')
  2 Kommentare
Andreas S
Andreas S am 10 Okt. 2020
Thank you very much! It worked for me.
Matt J
Matt J am 10 Okt. 2020
You're welcome, but please Accept-click the answer to certify that it worked.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by