How to write a matlab code to perform moving compuation for any equation?
조회 수: 1 (최근 30일)
이전 댓글 표시
Kalasagarreddi Kottakota
2023년 1월 8일
편집: Sulaymon Eshkabilov
2023년 1월 8일
Lets say I have a vector of 1000 random numbers and want to sum every 30 numbers of the vector and store it in a variable.
댓글 수: 0
채택된 답변
Sulaymon Eshkabilov
2023년 1월 8일
편집: Sulaymon Eshkabilov
2023년 1월 8일
There are a couple of ways to do it, e.g.:
V = randi([-10, 100], 1, 1000);
n = 1:30:numel(V);
for ii=1:numel(n)-1
Vs(ii)=sum(V(n(ii):n(ii+1)));
end
numel(Vs)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!