moving array in a vector
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi all, I need your kind support as I really confused to write moving array, let say for a simplified example i have an array vector of,
H = [1 2 3 4 5 6]
with the bracket of array is size of 4 elements.
The first bracket display, J1 = [1,2,3,4]
Then, it move, J2 = [2,3,4,5]
Then, it move further to end, J3 = [3,4,5,6]
Thank you very much in advance.
댓글 수: 1
Rik
2023년 2월 14일
You want to implement your own version of functions like movmean, movstd, etc? Why exactly? And what have you tried?
답변 (1개)
Shushant
2023년 2월 15일
According to the example provided by you I have made a small code snippet which simulates the moving array. I hope this solves your confusion.
H = [1 2 3 4 5 6];
bracket = 4;
J={};
for x = 1:size(H,2)-bracket+1 % run till element whose index + bracket is less than the size of vector H.
J{x} = H(x:bracket+x-1); % store elements in bracket to the variable J.
end
J
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!