fonefix
fonefix

Reputation: 39

How to get the length of a time vector in seconds?

I load an audio file and get sample and sampleRate with

[sample, sampleRate] = audioread(audiofile);

I want to get the length of the audio in seconds, how do I proceed?

Upvotes: 0

Views: 442

Answers (1)

Irreducible
Irreducible

Reputation: 899

Having the sampleRate, the inverse of it is the sampling time.

Ts=1/sampleRate;

So the time vector for your sampled data would be

time=(0:(length(sample)-1))*Ts;

Upvotes: 2

Related Questions