How can I create a data set with multiple random plots?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
ampaul
am 7 Jun. 2017
Kommentiert: Greg Heath
am 7 Jun. 2017
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 Kommentar
Greg Heath
am 7 Jun. 2017
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
Akzeptierte Antwort
Ali Ridha Ali
am 7 Jun. 2017
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Sequence and Numeric Feature Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!