How can I create a data set with multiple random plots?
1 次查看(过去 30 天)
显示 更早的评论
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
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
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File 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!