get y values of z values in spectrogram
조회 수: 1 (최근 30일)
이전 댓글 표시
Hii there. I want to get the y-values for specific z-values from a spectrogram. I just want to get the y-values for (z > -10).
This is my code for plot the spectrogram:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% load a signal
[x, fs] = audioread('file.wav'); % load an audio file
x = x(:, 1); % get the first channel
% determine the signal parameters
xlen = length(x); % signal length
t = (0:xlen-1)/fs; % time vector
% analysis parameters
wlen = 1024; % window length (recomended to be power of 2)
nfft = 4*wlen; % number of fft points (recomended to be power of 2)
hop = wlen/4; % hop size
TimeRes = wlen/fs; % time resulution of the analysis (i.e., window duration), s
FreqRes = 2*fs/wlen; % frequency resolution of the analysis (using Hanning window), Hz
% time-frequency grid parameters
TimeResGrid = hop/fs; % time resolution of the grid, s
FreqResGrid = fs/nfft; % frequency resolution of the grid, Hz
% perform STFT
w1 = hanning(wlen, 'periodic');
[~, fS, tS, PSD] = spectrogram(x, w1, wlen-hop, nfft, fs);
Samp = 20*log10(sqrt(PSD.*enbw(w1, fs))*sqrt(2));
% plot the spectrogram
figure;
surf(tS, fS, Samp);
shading interp;
axis tight;
box on;
set(gca, 'FontName', 'Times New Roman', 'FontSize', 12);
ylim([0 1500]);
xlim([0 2]);
xlabel('Time, s');
ylabel('Frequency, Hz');
title('Unterarm Messung Ruhepuls');
view(0, 90);
colormap('jet');
hcol = colorbar;
set(hcol, 'FontName', 'Times New Roman', 'FontSize', 12)
ylabel(hcol, 'Magnitude, dB')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Measurements and Spatial Audio에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!