# use of different time windows and time shift

9 views (last 30 days)
aa on 15 Aug 2020
Commented: aa on 15 Aug 2020
Hi All,
I have a problem in implementaion of for loop.
I have data in two coloumn: (a) Number of hours (b) parameter variation
I want to see teh change of paramter for diffrent time windows and diffrent time shifts and then use the output in an equation For exmaple, at first stage i want to calcualte paramter for 1 hour time window with a shift of 1 hour. then two hour time window with a shift of 1 hour, so on and so far.
then i want to calculate change in 4 hour with a time shift of 2 hour or three hours or 4 hours and so on ...
b=((u-(r).*(dt)./std
here u is the sum of enetires in each time window, r is a fix value say 0.33 ... dt is the length of tim window (2 hours or 3 or 4) and std is also fixed value say 0.5
I have to calculate the value of b for different timw windows and diffrent time shifts. (a raw data attached)
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Walter Roberson on 15 Aug 2020
c = cumsum([0,data]) ;
Then for window dt with shift s
(c(dt+1:s:end) - c(1:s:end-dt)). * dt .* (r/std)
does all the slots at the same time.
##### 3 CommentsShowHide 2 older comments
aa on 15 Aug 2020
i am trying to work on the code you proposed but it did not work. May you please used the field i attached here and the calculate the outpout.

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!