How to check the sum of a fixed row interval, as the interval steps forward by 1 throughout a 8784x1 vector?

1 view (last 30 days)
I've tried to use the reshape command, but the following;
reshape(sum(reshape(sensor_data,6,[])),[],1)
only summing 6 rows succesive at each calculation. I want to iteratively move (by 1) the fixed 6-row interval throughout the 8784 rows calculating the sum of that specific interval at each step.
  2 Comments
James Tursa
James Tursa on 6 Oct 2017
Please provide a short example. E.g., with a specific 24-element vector (1:24)', what would be the desired result?
Sebastian Engelsgaard
Sebastian Engelsgaard on 6 Oct 2017
Example: vector = randi([0 1], 24,1) %A 24x1 vector consiting of ones and zeros. Summing rows from 1 to 4 maybe results in 3, whereas summing 2 to 5 results in 1 dependent on randi function. Both of above-mentioned range of rows is 4. It has to sum row 1 to 4, and hereafter 2 to 5, and this is followed by the sum of 3-6. This is done until reaching the 24th element. Aiming this operation, i'll try to use a if-loop to check whether these sums is >, < or equal to 2.

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 6 Oct 2017
The movsum (link) function (introduced in R2016a) will probably do what you want.
  4 Comments
Cedric
Cedric on 7 Oct 2017
Hi Star, my pleasure!
(I had 5 minutes to kill on my cell phone while waiting for someone, and that did the trick ;) )

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!