Adding duration in second as x axis
4 views (last 30 days)
Show older comments
I have recorded and saved the sound signal and now would like to recreate the plot same as displayed using dsp.timeScope object.
plot(duration,data)
I have tried duration = start:step:end but it ended up having an extra 1 more data point in duration.(Must start with 0 not 1) Is there anyway to overcome this problem? Sampling rate is 44100Hz
0 Comments
Accepted Answer
dpb
on 10 Jun 2018
Don't alias the builtin duration; that will create problems working with time objects.
You don't really want a duration, you just want sampled time.
dt=1000/44100; % sampling time, ms
N=(length(data); % number samples in record
T=(length(data)-1)*dt; % sample time, ms
t=linspace(0,T,N); % make the time vector match the size of the data stream
plot(t,data) % plot, axis will be in msec; adjust xlim, xtick as wanted
If you really, really wanted to use one of the fancier ML features, use a timeseries
More Answers (0)
See Also
Categories
Find more on Signal Generation and Preprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!