I had never seen this fourier
command before. From what I gather, it returns the expression for the Fourier transform of the input to the command, specified as a symbolic expression. Think of it as giving you the actual expression for the Fourier Transform you would get by computing it with pen and paper.
Will this recorded object recObj be considered as continuous time signal or discrete time signal?
To be precise, this recObj
object is an object of type audiorecorder
. The function getaudiodata()
applied to this object gives you access to the sampled data, i.e. discrete data.
How can we get its frequency domain representation? Using 'fourier' command?
No. You would use the DFT (Discrete Fourier transform), available through the fft function for example, if your signal is stationary. If your signal is non-stationary (speech or music for example), you would want to have a time-frequency representation of your data, to see how the frequency content changes over time. For this, you could use the STFT (Short Time Fourier transform), available through the spectrogram function
Let's go through the example you're using, and I'll add some precisions for you:
% Define sampling and recording parameters:
Fs = 44100; % sampling frequency
nBits = 16; % number of bits used to represent each sample of the discrete data
nChannels = 1;
ID = -1; % default audio input device
% Initialize an audiorecorder object
recObj = audiorecorder(Fs,nBits,nChannels,ID);
% Record: speak or sing, the data is continuous when it reaches the microphone on your device, and goes through an Analog to Digital converter that samples it. The data stored is now discrete.
disp('Start speaking.')
recordblocking(recObj,5);
disp('End of Recording.');
For illustration purposes, this is what I get when recording the phrase:
$$
\textit{I hope this answer helps you}$$
Let's first look at the frequency content, using fft
:
% get the discrete data out of recObj
x = getaudiodata(recObj);
% Get the frequency content
N = length(x);
X = fft(x,N); X = X(1:N/2);
psd = 2*abs(X).^2/(Fs*N); % Power spectral density, don't worry about the scaling too much for now.
% Plot the frequency content
figure(1)
freqVec = (0:N/2-1)*Fs/N;
plot(freqVec, 10*log10(psd));
xlabel('Frequency (Hz)');
ylabel('Power (dB/Hz)');
grid on

Not much to see right? That's because what you recorded probably has frequencies that vary over time. Let's go to a time-frequency representation, using spectrogram
:
% Get the time-frequency content
winLength = 4096;
[s,t,f] = spectrogram(x, winLength, winLength/4, winLength, Fs);
% Plot
figure(2)
surf(f,t,10*log10(abs(s).^2),'edgecolor','none');
axis tight; view(0,90);
xlabel('Time (s)')
ylabel('Frequency (Hz)')

Try it out, and let us know if anything is unclear!