What is the solution for below code? It shows error
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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);
0 Commenti
Risposte (1)
Star Strider
il 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 Commenti
Star Strider
il 19 Feb 2019
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.
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!