Spectrogram error with multiple errors

5 ビュー (過去 30 日間)
Krithika A
Krithika A 2018 年 9 月 20 日
コメント済み: Krithika A 2018 年 10 月 3 日
Hello,
I keep getting the following error when I try to do a spectrogram: Subscript indices must either be real positive integers or logicals.
Error in getSTFTColumns (line 14) xin = x(rowindices+coloffsets);
Error in pspectrogram (line 55) [xin,t] = getSTFTColumns(x,nx,nwin,noverlap,Fs);
Error in spectrogram (line 168) pspectrogram({x},'spect',varargin{:});
This is what I am doing:
% Trying to use this code: spectrogram(x,window,noverlap,f,fs) so that I can see the spectrogram in terms of frequency and time
% x is my signal
% fs = 128
% N = 15360
% The frequency range I want to look at is between 2-35Hz
figure
spectrogram(x,hanning(2*fs),0.5,[2 35],fs)
  4 件のコメント
Rishabh Rathore
Rishabh Rathore 2018 年 10 月 1 日
編集済み: Rishabh Rathore 2018 年 10 月 1 日
Can you please share your signal "x" and a screenshot of the error message(or messages). And is "N" number of samples?
Krithika A
Krithika A 2018 年 10 月 1 日
I've attached the signal (.mat). The error messages are exactly like the ones I mentioned in the original post. Restated here:
Subscript indices must either be real positive integers or logicals.
Error in getSTFTColumns (line 14)
xin = x(rowindices+coloffsets);
Error in pspectrogram (line 55)
[xin,t] = getSTFTColumns(x,nx,nwin,noverlap,Fs);
Error in spectrogram (line 168)
pspectrogram({x},'spect',varargin{:});

サインインしてコメントする。

採用された回答

Rishabh Rathore
Rishabh Rathore 2018 年 10 月 3 日
The "noverlap" should be a positive integer as it represents the number of samples of overlap with previous window. Hence the 50% overlap would be floor(win_size/2).
I'm attaching the figure that I obtained after making the changes using your input signal.
Since your window size is 2*fs, the 50% overlap will be "fs". Hence the use of the function "spectrogram" should look like: -
spectrogram(x,hanning(2*fs),fs,[2 35],fs);
  1 件のコメント
Krithika A
Krithika A 2018 年 10 月 3 日
Thank you very much! That's brilliant, no errors. Also, thank you for explaining what was wrong.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTime-Frequency Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by