How do I create a repeating number series?
Show older comments
Hi guys,
I am doing some work with data taken every 30 minutes over a period of 5 years. For one of the equations I need to use in the programme, it requires a term called 'h', which refers to the midpoint of the calculation period, with units of hours (written as a decimal) of the day. For instance, for the midpoint between 14:00 and 14:30, h=14.25, and for the midpoint of 14:30 and 15:00, h=14.75.
My problem is generating this term h to use in equations.
My total value for the amount of terms in this dataset is a value around 87,000.
So far I have made this:
h=0.25;
n=49;
for i=1:n
h(i+1)=h(i)+0.5
end
which generates:
Columns 1 through 11
0.2500 0.7500 1.2500 1.7500 2.2500 2.7500 3.2500 3.7500 4.2500 4.7500 5.2500
Columns 12 through 22
5.7500 6.2500 6.7500 7.2500 7.7500 8.2500 8.7500 9.2500 9.7500 10.2500 10.7500
Columns 23 through 33
11.2500 11.7500 12.2500 12.7500 13.2500 13.7500 14.2500 14.7500 15.2500 15.7500 16.2500
Columns 34 through 44
16.7500 17.2500 17.7500 18.2500 18.7500 19.2500 19.7500 20.2500 20.7500 21.2500 21.7500
Columns 45 through 50
22.2500 22.7500 23.2500 23.7500 24.2500 24.7500
This is what I want, however this only represents one day. I want to make this series repeat so after 24.75 of one day, the sequence resets to 0.25 for the new day and this sequence repeats itself for every day in the dataset, which is all 87,000 data points. How would I do this?
Thanks, Rob
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices 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!