# generate time series

4 views (last 30 days)
Richard on 22 Jun 2012
I would like to generate a time series for one year of hourly values, so for 2011 ti would 8760 values within the series. To make it easier to understand what I am trying to do I will use a real world example:
If we had a time series of hourly air temperature measurements an then plotted the entire series it would look similar to a bell shaped curve i.e.
a = 0; b = 30;
x = a + (b-a) * rand(1, 8760);
m = (a + b)/2;
s = 12;
p1 = -.5 * ((x - m)/s) .^ 2;
p2 = (s * sqrt(2*pi));
f = exp(p1) ./ p2;
plot(x,f,'.')
with the maximum values occurring in mid summer and lowest values during the winter. However, by zooming in on specific days we would see that the temperature also fluctuates between the day and the evening where maximum temperatures would occur at approximately 15:00 and minimum temperature at approximately 06:00.
So, my question is how would I generate series which had a maximum value of say 30 degrees in mid summer i.e. value (8760/2) and also had the daily pattern mentioned above incorporated into the overall pattern?

Wayne King on 22 Jun 2012
You could add in a periodic component cos() or sin() with a small amplitude that fluctuated with the correct period so that it would reach its maximum at 15:00 and minimum around 06:00

### Categories

Find more on Time Series 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!

Translated by