How to take data on a column matrix (2661 x 1 double) for every 4 row then 3, sequently? So we take data only row 1, 5, 8, 12, 15, 19, 22, ... etc? Thank you.

1 view (last 30 days)

Accepted Answer

Alan Stevens
Alan Stevens on 26 Oct 2021
Here's one way. There's probably a neater way.
data=rand(1,2661);
n = ceil(2661/3.5);
ptr(1)=1;
for i = 2:n
ptr(i) = 4*(mod(i,2)==0) + 3*(mod(i,2)==1) + ptr(i-1);
end
data2 = data(ptr);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by