Question

I create a matlab gui and have some element in it with some axes. I plot one of my desire plot in ploter1 ( first axes ) using

plot(handles.ploter1,xx); title(handles.ploter1,'Waveform');

and it is ok,but I want use specgram and plot specgram result in another axes by I dont know how can do it :(
I test

specgram(wav,N,fs,hamming(N/4),round(0.9*N/4));xlabel('time, s');

or

specgram(handles.ploter2,wav,N,fs,hamming(N/4),round(0.9*N/4));xlabel('time, s');

but return me error or nothing !!! enter image description here

please help me. thank you very much

Était-ce utile?

La solution

EDIT

as mentioned in the comments by bdecaf, what should work, is to set the current axes:

axes(handles.ploter2);

now, when using just

spectrogram(x,window,noverlap,F)]

the plot should be on the specified axes. If not, try:

hold on

before!

OLD

specgram or spectogram does not have a parameter for the plot. You have to define it later on.

I suggest to get the result first by:

[S,F,T]=spectrogram(x,window,noverlap,F)]

and then plot it on a specific axes:

plot(handles.ploter2, S,F)

But I am not sure about which parameter you want to plot. Please take a look at the docs.

From the docs:

[S,F,T] = spectrogram(...) returns a vector of frequencies, F, and a vector of times, T, at which the spectrogram is computed. F has length equal to the number of rows of S. T has length k (defined above) and the values in T correspond to the center of each segment.

[S,F,T] = spectrogram(x,window,noverlap,F) uses a vector F of frequencies in Hz. F must be a vector with at least two elements. This case computes the spectrogram at the frequencies in F using the Goertzel algorithm. The specified frequencies are rounded to the nearest DFT bin commensurate with the signal's resolution. In all other syntax cases where nfft or a default for nfft is used, the short-time Fourier transform is used. The F vector returned is a vector of the rounded frequencies. T is a vector of times at which the spectrogram is computed. The length of F is equal to the number of rows of S. The length of T is equal to k, as defined above and each value corresponds to the center of each segment.

[S,F,T] = spectrogram(x,window,noverlap,F,fs) uses a vector F of frequencies in Hz as above and uses the fs sampling frequency in Hz. If fs is specified as empty [], it defaults to 1 Hz.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top