How can I create a data set with multiple random plots?

1 回表示 (過去 30 日間)
ampaul
ampaul 2017 年 6 月 7 日
コメント済み: Greg Heath 2017 年 6 月 7 日
I am trying to develop a random time series data set to use in training a neural network. I would like to mention that I am very new to Matlab.
This is the equation I'm working with: test = µ + r(t)σ + gt
where µ (mean value) = 3 t (time in seconds) = 1:1:20 σ (noise level) = 5 g (magnitude of gradient trend) = 2 r = normally distributed random number
This equation should show an upward trend in the data, correct? I would like for this equation to plot multiple y values over my x values (time).
When I plot this data using r=rand, it just plots a linear graph.
Can you help me find out what I'm doing wrong? Thanks
  1 件のコメント
Greg Heath
Greg Heath 2017 年 6 月 7 日
In general, whenever you ask a question:
1. Please post the exact executable code, not just your interpretation.
2. If applicable, use the code in the help and doc documentation. For example, see
help timedelaynet
and/or
doc timedelaynet
3. If additional data is needed, use MATLAB data obtained from
help nndatasets
and/or
doc nndatasets
4. This will save a lot of time and misunderstanding.
Hope this is helpful.
Greg

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

採用された回答

Ali Ridha Ali
Ali Ridha Ali 2017 年 6 月 7 日
mu=3; % mean value
s=1; % stepsize >> decrease it to get more points
P=1:s:20; % time period
sigma=5; % noise level
g=2; % magnitude of gradient trend
for t=1:length(P)
y(t) = mu + sigma*rand + g*t;
end
plot(P,y);xlabel('time in seconds');ylabel('y');grid;
If you run the above code, you will get you randomly generated plot; such as the following generated below (it will variate based on the value of rand)
Also, because your function is very simple, so you can do that without using for-loop as follows:
mu=3; % mean value
s=1; % stepsize >> decrease it to get more points
P=1:s:20; % time period
sigma=5; % noise level
g=2; % magnitude of gradient trend
RND=rand(1,length(P)); % to generate a vector of random numbers equal to the time period length
y = mu + sigma*RND + g*P;
plot(P,y);xlabel('time in seconds');ylabel('y');grid;
I hope this will help
  1 件のコメント
ampaul
ampaul 2017 年 6 月 7 日
Thank you. That is exactly what I was looking for.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSequence and Numeric Feature Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by