What is the solution for below code? It shows error

t=0:0.001:2; %sec @ 1 khz sample rate
x=chirp(t,0,1,150); %start @ DC ,cross 150 HZ at t=1 sec
F=0:.1:100;
[y,f,t,p] = spectrogram (x,256,250,F,1E3,'yaxis');
% 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('Frequench (HZ)');
[y,fs] =audioread('filename.wav');
NW=round(fs*0.025);
[,F,T,P]= spectrogram(y,NW,[],[],fs);
Error using Spectrogram>chkinput (
line252)
Xmust be a vector(either row or column)
Error in spectrogram (line166) chkinput (x);

Antworten (1)

Star Strider
Star Strider am 18 Feb. 2019
I suspect the error refers to this assignment:
[,F,T,P]= spectrogram(y,NW,[],[],fs);
(that also seems to be missing an output, so it will throw an error). I assume that you intend:
[Y,F,T,P]= spectrogram(y,NW,[],[],fs);
Note that the second assignment to ‘y’ is the result of:
[y,fs] =audioread('filename.wav');
and if ‘y’ is a stereo signal, it will have 2 columns, so check that with the size function. The most likely correction is to choose one of them for each spectrogram call.

12 Kommentare

Yasir Ali
Yasir Ali am 18 Feb. 2019
star strider May I have your email Id plz as I can contact with you .
I do not use email for MATLAB Answers threads. I prefer to keep everything here.
Yasir Ali
Yasir Ali am 18 Feb. 2019
actually , Iam worried Iam new to matlab I have to extract audio frequency in different parts for example I have a 5 seconds wav file I want to read there Some micro seconds and their frequency spectrum like 0.030 ms , I need code for it in which I can easily get frequency response in different parts ,your help will highly appreciated .
Nothing that can't be worked on here instead of in private emails.
Yasir Ali
Yasir Ali am 18 Feb. 2019
image analyst its ok , help me here to get solution of my problem
@Image Analyst — Thank you. My sentiments exactly.
@Yasir Ali — Private email disrupts the flow of the conversations here. For many reasons, that is not desirable.
Yasir Ali
Yasir Ali am 18 Feb. 2019
you seniors are absolutely right .
@Star Strider I explain my Querry can you help me to solve it ?
@Yasir Ali — I have done my best with the information you provided. If you have more information to share, I will do my best to help you solve your problem.
Yasir Ali
Yasir Ali am 19 Feb. 2019
Star Strider I have wav file of five seconds , I want to read wav file freqeuncy spectrum in Micro seconds/miliseconds e.g from five seconds I want frequency response of 0.030 ms , or in different parts .
Please read the spectrogram documentation and adjust your variables to what it requires.
Yasir Ali
Yasir Ali am 19 Feb. 2019
I gone through it but Iam not understanding how to adjust according my choice I have try my level best but I unable to find a good result as I am not much familiar with matlab programming thats why Iam asking to help for coding .
The documentation describes all of this much better than I can. You will likely have to experiment with your code until it does what you want it to.
That is how I learned programming, and likely how the rest of us here learned.

Melden Sie sich an, um zu kommentieren.

Kategorien

Gefragt:

am 18 Feb. 2019

Kommentiert:

am 19 Feb. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by