|
"Ashish Uthama" <first.last@mathworks.com> wrote in message
news:op.u02ox9l7a5ziv5@uthamaa.dhcp.mathworks.com...
> On Wed, 30 Sep 2009 09:43:03 -0400, Clement Lim
> <clementlim@singnet.com.sg> wrote:
>
>> Hi All,
>> I had the following code. I wish to use the movie function to animate my
>> histogram but I had tried various way and the below code still cannot
>> perform correctly. Can anyone help me? Tks
>>
>> [filename, pathname] = uigetfile('*.*', 'Pick any file');
>> [y, fs, nbits] = wavread(filename);
>>
>> [S,S,T,P]=spectrogram(y);%returns the spectrogram of the signal
>> specified by vector y in the matrix S(1st S),vector of frequencies S(2nd
>> S), vector of times T, P is the PSD
>> subplot(2,1,1);
>> spectrogram(y);
>> title('Spectrogram');
>> subplot(2,1,2);
>> for k = 1:16
>> plot(Y)
>> axis equal
>> M(k) = getframe;
>> end
>> arg={S,T,10*log10(abs([P.'])+eps)};
>> waterfall(arg{:});
>> colormap(jet(256));
>> movie(M,10)
>> title('Waterfall Plot');
>
> What is 'Y' in the call to PLOT? You use 'y' elsewhere.
>
> The PLOT does not appear to change inside the FOR loop, wouldn't you
> expect M(k) to be the same for all values of k ?
>
>
also, for it to work correctly, you need to include the pathname when
calling wavread, something like:
[y, fs, nbits] = wavread([pathname filename]);
I have tried this with a wav file provided by Windows and y is of dimension
two (presumably because it's in stereo), and you can only call spectogram
with a vector signal, so you need to do something like:
[S,S,T,P]=spectrogram(y(:,1)); or [S,S,T,P]=spectrogram(y(:,2));
and then again when plotting:
spectrogram(y(:,1)); or spectrogram(y(:,2));
HTH.
Arnaud
|