📄 sgram_go.m
字号:
%
% Callback function for Spectrogram button in the Frequency Analysis window
% Author : Minkyu Lee
% Date : 4-Feb-1995
% Modified by Karthik May 27 1997
% Modified by D. G. Childers
speech1=SPEECH_OLD(LEFT:RIGHT);
% Set position and size of analysis window
PV=[275 100 519 240];
s2 = 'Frequency Domain Analysis - Output';
% Open analysis window
while exist('freq_out_win_h')==1
try1 = 'get(freq_out_win_h,''position'');';
eval(try1,catch2);
if check ==0
clear freq_out_win_h;
check = 1;
break;
end
s1 = get(freq_out_win_h,'Name');
if ~strcmp(s1,s2)
clear freq_out_win_h;
break;
end
figure(freq_out_win_h);
break;
end;
if exist('freq_out_win_h')~=1;
freq_out_win_h=figure('Position',PV,...
'Resize','on',...
'Numbertitle','off',...
'Name',s2);
end
if (RIGHT-LEFT+1) < sgram_frame_len
disp('The current data length is less than the analysis frame length');
disp('The analysis will continue with the frame length being set to ');
disp('the length of the data.');
sgram_frame_len=RIGHT-LEFT+1;
end
if sgram_window == 1
window = hamming(sgram_frame_len); % Window type
elseif sgram_window == 2
window = hanning(sgram_frame_len); % Window type
elseif sgram_window == 3
beta=0.5;
window = kaiser(sgram_frame_len,beta); % Window type
elseif sgram_window == 4
window = triang(sgram_frame_len); % Window type
elseif sgram_window == 5
window = bartlett(sgram_frame_len); % Window type
elseif sgram_window == 6
window = blackman(sgram_frame_len); % Window type
elseif sgram_window == 7
window = boxcar(sgram_frame_len); % Window type
elseif sgram_window == 8
rdb=3;
window = chebwin(sgram_frame_len-1,rdb); % Window type
end
% set other parameters
Fs = 10000; % Sampling frequency
sgram_overlap_len=round(sgram_overlap*1/100*sgram_frame_len); %calculate the overlap in data points, not percentage.
if sgram_overlap_len==sgram_frame_len
sgram_overlap_len=sgram_overlap-1;
end
% call Matlab function to calculate spectrogram from input signal
[B,F,T] = specgram ( speech1, sgram_frame_len, Fs, window, sgram_overlap_len );
time=LEFT:RIGHT+500;
% plot the spectrogram
imagesc(time,F,-20*log10(10+abs(B))),axis('xy'), colormap(jet);
%imagesc(T,F,-20*log10(400+abs(B)));
title('spectrogram');
xlabel('time [s]')
ylabel('frequency [Hz]');
clear speech1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -