필터 지우기
필터 지우기

Code running multiple times for different elements of a matrix

조회 수: 1 (최근 30일)
Andreas S
Andreas S 2020년 10월 9일
댓글: Matt J 2020년 10월 10일
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.
  댓글 수: 1
Matt J
Matt J 2020년 10월 9일
I think you mean,
m360=mean(ret(360:479,1:10))
m361=mean(ret(361:480,1:10))

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2020년 10월 9일
편집: Matt J 2020년 10월 9일
m=conv2(ret,ones(120,1)/120,'valid')
  댓글 수: 2
Andreas S
Andreas S 2020년 10월 10일
Thank you very much! It worked for me.
Matt J
Matt J 2020년 10월 10일
You're welcome, but please Accept-click the answer to certify that it worked.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by