Save data with different intervals?
6 次查看(过去 30 天)
显示 更早的评论
I have an array of data and I need to discard the first 7 values, save 15 values and discard other 7 values and keep going until the end of the array.
What is the easiest way to do it? I've tried with a for loop but I don't know how to set the index.
Also, if i want to, let's say, add or subtract a points every 4 repetitions how could I do it? So after 4 times I discard 7 values and save the following 16 values.
Thanks in advance if someone will help me, I'm very stucked.
1 个评论
采纳的回答
Walter Roberson
2021-8-8
编辑:Walter Roberson
2021-8-8
temp = reshape(YourVector, 7+15, []);
to_save = reshape(temp(8:end,:), 1, []);
So after 4 times I discard 7 values and save the following 16 values.
temp = reshape(YourVector, 7+15+7+15+7+15+7+16, []);
temp([22*0+(1:7), 22*1+(1:7), 22*2+(1:7), 22*3+(1:7)],:) = [];
to_save = reshape(temp, 1, []);
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!