spectogram and frequency spectrum values problem

조회 수: 3 (최근 30일)
MARKOS DERMITZAKIS
MARKOS DERMITZAKIS 2015년 11월 11일
편집: MARKOS DERMITZAKIS 2015년 11월 11일
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개)

카테고리

Help CenterFile Exchange에서 Filter Analysis에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by