1
這裏我繪製一張光譜圖兩次,一次使用imagesc,一次使用光譜圖自動繪圖。我不知道爲什麼我會得到不同的縮放比例結果,可能是由自動繪圖功能進行過濾,但我想知道究竟是什麼以及如何對其進行轉換以使其匹配。這兩個地塊爲什麼不同?
fs = 44100;
% Frequency sweep signal
sw = logspace(log10(500),log10(5000),fs*5);
x = 0.95 * sin(cumsum((2*pi*sw)/fs));
N = 128;
win_size = N;
noverlap = N/2;
win = window(@blackman,win_size);
[s,f,t] = spectrogram(x,win,noverlap,N,fs,'yaxis');
%% IMAGESC --- FIGURE 1
figure(1)
imagesc(t,f/1000,20*log(abs(s)));
title('Spectrogram');
set(gca,'Ydir','Normal');
xlabel('Time (secs)');
ylabel('Frequency (kHz)');
hcb=colorbar;
title(hcb,'Spectral Magnitude (dB)');
%% test with automatic spectrogram plot ---FIGURE2
figure(2)
spectrogram(x,win,noverlap,N,fs,'yaxis');
end
幫助表示讚賞:)