Hi,
Based on my understanding of the given conditions, I think you are on the right track to generate the output. The logic needs to be extended to handle the intermediate elements. Here is an updated code that should handle the conditions and generate the required output:
output = [];
for i = 6000 : 3000 : length(YourVector)
if abs(YourVector(i) - YourVector(i-3000)) > 10
output = [output, YourVector(i+[0 100 200 300 400 500])];
% Check intermediate elements dynamically
for j = 100:100:500
if abs(YourVector(i+j) - YourVector(i+j-100)) > 10
output = [output, YourVector(i+[600 700 800 900 1000])];
break; % Exit loop if condition is met
end
end
else
output = [output, YourVector(i)];
end
end
The nested loop checks each intermediate element (100th, 200th, 300th, 400th, 500th) dynamically. If any of these elements differ from their preceding element by more than 10, it adds the next 5 samples (600th, 700th, 800th, 900th, 1000th) to the output array and breaks out of the loop.
Hope this helps!