필터 지우기
필터 지우기

how to fix the following error?

조회 수: 6 (최근 30일)
Yasir Ali
Yasir Ali 2019년 3월 26일
댓글: Jan 2019년 4월 4일
dear Seniors and Experts I need solution for following code kindly help me to fix it .
data is
y=195840*2 double
fs=48000
t=0:0.001:2; % 2 secs @ 1kHz sample rate
x=chirp(t,0,1,150); % Start @ DC, cross 150Hz at t=1sec
F = 0:.1:100;
[y,f,t,p] = spectrogram(x,256,250,F,1E3,'yaxis');
% NOTE: This is the same as calling SPECTROGRAM with no outputs.
surf(t,f,10*log10(abs(p)),'EdgeColor','none');
axis xy; axis tight; colormap(jet); view(0,90);
xlabel('Time');
ylabel('Frequency (Hz)');
[y,fs]=audioread('Mithe Mustafa Tey 5sec.mp3');
NW = round(fs*0.250);
[S,F,T,P] = spectrogram(y,NW,[],[],fs);
Error using spectrogram>chkinput (line 252)
X must be a vector (either row or column).
Error in spectrogram (line 166)
chkinput(x);
while I click on line 252 and 166 it shows this
line 252 = error(message('signal:spectrogram:MustBeVector', 'X'));
line 166 = chkinput(x);

채택된 답변

Yasir Ali
Yasir Ali 2019년 3월 26일
Thanks Dear walter If I wish to plot both channels then how to do that?
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 3월 26일
subplot(1,2,1)
spectrogram(y(:,1), NW, [], [], fs);
title('left channel')
subplot(1,2,2)
spectrogram(y(:,2), NW, [], [], fs);
title('right channel')
Jan
Jan 2019년 4월 4일
@Yasir: This is not an answer, which solves the question. Marking it as "accepted" means, that your problem is solved by this answer. Please post comments in the section for comments.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2019년 3월 26일
Your mp3 is stereo, 2 channels. spectrogram() can only process one channel at a time.
You need to do one of the following:
  1. Choose one of the two channels and only process that one; or
  2. combine the two channels into one, such as by using mean(); or
  3. call spectrogram twice, once for each of the channels.
  댓글 수: 6
Yasir Ali
Yasir Ali 2019년 3월 26일
편집: Walter Roberson 2019년 3월 30일
Dear walter one last guideline require I found your comments very helpful
In above code I have try to get frequency response of audio in milisecond is it good code for getting frequency in miliseconds? ?
And when I try to get spectrum above 300 like 350 ms or more than error comes index dimension exceeds.
Walter Roberson
Walter Roberson 2019년 3월 30일
I am not sure. My calculation at the moment is that with your window of 256 that you would get resolution to about 375 Hz, but I do not trust those calculations at all.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by