Time axis explanation required

1 次查看(过去 30 天)
Saad Rana
Saad Rana 2020-6-7
Hi,
I am recording my 3 seconds voice signal to plot it in a graph. But the time axis in the graph seem strange. I am recording 3 second audio so to my understanding time axis should be from 0-3 but it shows values in [x10^5]. I asked another question here and foud out the code that plots the x axis but I cannot undeerstand how is it being plotted. Here's my code:
fs = 48000;
rec1 = audiorecorder(fs,16,1);
recordblocking(rec1, 3);
myRec1 = getaudiodata(rec1);
time = length(myRec1)/fs
ti = 0:time:(length(myRec1)*time)-time;
axes(handles.orignal)
plot(ti,myRec1)
If I write:
plot(time,myRec1)
it does not plot saying vectors must be of same length. So can anyone explain to me how is this line working
ti = 0:time:(length(myRec1)*time)-time;
I mean like how is it values in [x10^5] and not 0-3 in the x axis?

回答(1 个)

David Goodmanson
David Goodmanson 2020-6-7
Hi Saad,
'time' is (almost) the total length of the time record, so it will not be the spacing when setting up the time array. Try
time = (length(myRec1)-1)/fs
timearray = linspace(0,time,length(myRec1))

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by