フィルターのクリア

How to generate random data which follows a specific pattern ?

25 ビュー (過去 30 日間)
S M Shahnewaz Siddiquee
S M Shahnewaz Siddiquee 2017 年 2 月 6 日
回答済み: dbmn 2017 年 2 月 6 日
I want to generate yearly Outdoor temperature data with 1 hr interval and having seasonal variation ( Summer, Winter ). There will be 8760 timesteps of data.In summer Temperature will vary around the range of 25-35 degree and In winter it will vary around -10 to 10 degree. I am a beginner in Matlab. Any suggestion or code reference would be very helpful

採用された回答

dbmn
dbmn 2017 年 2 月 6 日
As KSSV said, the random function generates data very nicely. But this distribution might need to be adapted to your needs.
To adjust to your problem you need to add the desired mean of your data and multiply the distribution.
mean_temperature = 15*sin(0:0.1:6)+15;
random_variation = rand(1, 61)*20-10;
plot(mean_temperature+random_variation)
And if you want a non uniform distribution, you need to multiply the random_variation with a function instead of the value 20.
hope this helps you get started

その他の回答 (1 件)

KSSV
KSSV 2017 年 2 月 6 日
There is a inbuilt command rand in matlab which generates Uniformly distributed random numbers between 0 and 1. doc rand. To generate random numbers in a given range [a,b]. You may follow:
a = 50;
b = 100;
r = (b-a).*rand(1000,1) + a;
  2 件のコメント
S M Shahnewaz Siddiquee
S M Shahnewaz Siddiquee 2017 年 2 月 6 日
編集済み: S M Shahnewaz Siddiquee 2017 年 2 月 6 日
Thanks Yes , I already checked that command but It doesn't give any option to user to generate numbers that follow a certain pattern
KSSV
KSSV 2017 年 2 月 6 日
Numbers follow uniform distribution. what pattern you are expecting?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by