필터 지우기
필터 지우기

How to write a matlab code to perform moving compuation for any equation?

조회 수: 1 (최근 30일)
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.

채택된 답변

Sulaymon Eshkabilov
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)
ans = 33

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by