- fft function: https://www.mathworks.com/help/matlab/ref/fft.html
- spectrogram: https://www.mathworks.com/help/signal/ref/spectrogram.html
find DFT , draw the spectrum ,sampling time case 1 take 10 sec and case 2 take 30 sec and draw spectrum for both the cases
2 views (last 30 days)
Show older comments
A sound control system has to be modelled with the help of statistical parameters. Modelling has to be done with the given speech signal “track.wav” and f(t) = Cos (200*pit*t) +3 Sin(500*pi*t). The signal is sampled at a rate of 100Hz. Plot the following waveforms using Matlab.
i. Signal in time domain (Time Vs Amplitude)
ii. Compute the discrete Fourier transform and plot the magnitude of the signal with respect to the frequency when the signal is sampled for 10 seconds and 30 seconds, comment on the differences you observe in your plots.
iii.Frequency of the signal with respect to time.
0 Comments
Answers (1)
Balavignesh
on 3 Jul 2024
Hi Raeesaha,
As per my understanding, you would like to do the modelling of a sound control system with a speech signal 'track.wav'. Make sure you have the file in your working directory.
Here is a functional code snippet that you might find useful:
% Load the speech signal
[speechSignal, fs] = audioread('track.wav');
% Define the time vector for the given sampling rate
t = 0:1/fs:(length(speechSignal)-1)/fs;
% Define the given function f(t)
f_t = cos(200*pi*t) + 3*sin(500*pi*t);
% Plot the signal in time domain
figure;
subplot(2,1,1);
plot(t, speechSignal);
title('Speech Signal in Time Domain');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(2,1,2);
plot(t, f_t);
title('f(t) = Cos(200*pi*t) + 3*Sin(500*pi*t)');
xlabel('Time (s)');
ylabel('Amplitude');
% Compute the Discrete Fourier Transform (DFT) for 10 seconds
n10 = fs * 10; % Number of samples for 10 seconds
f_speech10 = fft(speechSignal(1:n10));
f_f_t10 = fft(f_t(1:n10));
% Compute the Discrete Fourier Transform (DFT) for 30 seconds
n30 = fs * 30; % Number of samples for 30 seconds
f_speech30 = fft(speechSignal(1:n30));
f_f_t30 = fft(f_t(1:n30));
% Frequency vector for plotting
f10 = (0:n10-1)*(fs/n10);
f30 = (0:n30-1)*(fs/n30);
% Plot the magnitude of the DFT for 10 seconds
figure;
subplot(2,1,1);
plot(f10, abs(f_speech10));
title('Magnitude of DFT of Speech Signal (10 seconds)');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
subplot(2,1,2);
plot(f10, abs(f_f_t10));
title('Magnitude of DFT of f(t) (10 seconds)');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
% Plot the magnitude of the DFT for 30 seconds
figure;
subplot(2,1,1);
plot(f30, abs(f_speech30));
title('Magnitude of DFT of Speech Signal (30 seconds)');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
subplot(2,1,2);
plot(f30, abs(f_f_t30));
title('Magnitude of DFT of f(t) (30 seconds)');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
% Comment on the differences
% When comparing the DFT plots for 10 seconds and 30 seconds, you will notice that the
% frequency resolution improves with the longer sampling duration. This is because the
% frequency resolution is inversely proportional to the duration of the signal. Hence,
% the 30-second DFT plot will show more precise frequency components compared to the
% 10-second DFT plot.
% Compute the spectrogram to analyze the frequency of the signal with respect to time
figure;
spectrogram(speechSignal, 256, [], [], fs, 'yaxis');
title('Spectrogram of Speech Signal');
xlabel('Time (s)');
ylabel('Frequency (Hz)');
figure;
spectrogram(f_t, 256, [], [], fs, 'yaxis');
title('Spectrogram of f(t)');
xlabel('Time (s)');
ylabel('Frequency (Hz)');
Kindly have a look at the following documentation links to have more information on:
Hope that helps!
Balavignesh
0 Comments
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!