Time axis explanation required

조회 수: 2 (최근 30일)
Saad Rana
Saad Rana 2020년 6월 7일
답변: David Goodmanson 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