how to apply code some interval columns

1 次查看(过去 30 天)
I want to apply this code some interval of data
envelope(data,1,'peak')
[peakHeights,valleyHeights] = envelope(data,1,'peak')
vi = sum(peakHeights-valleyHeights)
[peakHeights, indexesOfPeaks] = findpeaks (data);
[valleyHeights, indexesOfValleys] = findpeaks (data);
fi = numel(indexesOfPeaks) + numel(indexesOfValleys)
for example
if data set is [ 1 2 3 4 4 3 5 3 2 3 5 6 7 7 3 5 6 7 1 9 2 4 6 7 8 8 4 3 2 2 5 5 ]
i want apply this code some interval (if 3 column ) like [1 2 3], [2 3 4], [3 4 4], [4,4,3].....[2 5 5] moving forward 1 colmumn.
so, i want to know how to apply code to some interval ( in here 3 column) in moving 1 column forward.
please let me know, thank you

采纳的回答

Ameer Hamza
Ameer Hamza 2020-10-14
You can write a for-loop
x = [ 1 2 3 4 4 3 5 3 2 3 5 6 7 7 3 5 6 7 1 9 2 4 6 7 8 8 4 3 2 2 5 5 ];
n = 3;
for i = 1:numel(x)-n+1
xi = x(i:i+2); % n-element vector
% process xi
end

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by