MATLAB Answers

extract data from a 1D vector with a pattern

3 views (last 30 days)
H H
H H on 22 Jul 2021
Commented: H H on 25 Jul 2021
I have a 1D vector A=[1:1000]. I would like to start from the first elemnt of A and automatcially extract every first 16 elemnts but exclude the next 8 elements, and continue to end. In the end I have two vectors A1 (has every chunks of 16 elemnets) and A2 (every other chunk of 8 elemnts). In other words, A1 and A2 should include the follwing elemnts of vector A:
A1=[A(1:16), A(25:40), A(49:64), etc]
A2=[A(17:24), A(41:48), A(65:72), etc]

Accepted Answer

Yongjian Feng
Yongjian Feng on 22 Jul 2021
Do it in a loop. Loop through 1 to 1000. Append elements to A1 and A2 inside the loop.
  2 Comments

Sign in to comment.

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!