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 CenterFile Exchange에서 Sequence 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