spectogram and frequency spectrum values problem
2 views (last 30 days)
Show older comments
hello all, I would like some help regarding my problem, which is to write a function that takes as input a one-dimensional waveform (a piano signal for this case), and plot its frequency spectrum and its spectrogram. I am not sure if the values I chose are correct and what to do in order to improve the whole thing.
[y,fs] = audioread('pia60.wav');
%sound(y,fs);
S = size(y); %size of y = 125031
Time = length(y)/fs; %duration of the recording
Time
t = [0:length(y)-1]/fs; %the time axis
plot(t,y); %plot the signal
xlabel('seconds');
grid on;
N = 20000;
y1 = y(60000:80000);
fft_vector = fft(y1,N);
m = abs(fft_vector); %we are interested only in the amplitude
x =(0:999)*Fs/N; %the frequency axis with the first 1000 elements
stem(x, m(1:1000)); %plot the frequency spectrum
xlabel ('Frequency [Hz]');
length(fft(y1,N))
%SPECTOGRAM
window = hann(512); %a window with a size of 512 points
noverlap = 256; %the number of noverlaps
nfft = 20000; %size of nfft
spectrogram(y, window, noverlap, nfft, fs)
0 Comments
Answers (0)
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!