spectogram and frequency spectrum values problem

1 回表示 (過去 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 Center および File ExchangeSpectral Measurements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by