MATLAB: Finding frequency and duration of an audio signal

audiofrequencyMATLABsignal processing

What is the frequency (not the sampling rate) and duration of this audio?
>> fs=24000.0; % Sampling rate
>> t=0:1/fs:1; % One sample each Ts=1/fs
>> x=cos(2pi1000t);
>> sound(x,fs);
I'm trying to learn signal processing … and I can't find the answer to this question anywhere.
Thanks in advance.

Best Answer

You specified it to be 1 kHz, and 1 second duration, so it is just that:
fs=24000.0; % Sampling rate
t=0:1/fs:1; % One sample each Ts=1/fs
x=cos(2*pi*1000*t);
sound(x,fs);
L = numel(t);
fn = fs/2;
FTx = fft(x)/L;
Fv = linspace(0, 1, fix(L/2)+1)*fn;
Iv = 1:numel(Fv);
figure
plot(Fv, abs(FTx(Iv))*2)
grid
xlim([0 2000])
The Fourier transform plot demonstrates it.