Last change
on this file since 94 was
51,
checked in by dtax, 12 years ago
|
Nicer plot function for a spectrogram.
|
File size:
763 bytes
|
Rev | Line | |
---|
[51] | 1 | % |
---|
| 2 | % SHOWSPEC(S) |
---|
| 3 | % SHOWSPEC(S,F,T) |
---|
| 4 | % |
---|
| 5 | % Show spectrogram S in a nice graph. When vectors F and T are given, |
---|
| 6 | % the appropriate frequencies (F) and timepoints (T) are plotted on the |
---|
| 7 | % vertical and horizontal axes, respectively. |
---|
| 8 | % When a spectrogram is constructed from the Matlab spectrogram.m, in |
---|
| 9 | % principle a complex-valued matrix S is obtained. If this is not |
---|
| 10 | % converted into something real-valued, the abs(S) is actually plotted |
---|
| 11 | % in the figure. |
---|
| 12 | |
---|
| 13 | function showspec(S,f,t) |
---|
| 14 | |
---|
| 15 | if ~isreal(S) |
---|
| 16 | S = abs(S); |
---|
| 17 | warning('showspec:NotRealS','Spectrum S is complex, using abs(S).'); |
---|
| 18 | end |
---|
| 19 | |
---|
| 20 | if nargin<2 |
---|
| 21 | imagesc(S); |
---|
| 22 | axis xy; |
---|
| 23 | xlabel('timepoint'); |
---|
| 24 | ylabel('frequency'); |
---|
| 25 | else |
---|
| 26 | imagesc(t,f,S); |
---|
| 27 | axis xy; |
---|
| 28 | xlabel('time (s)'); |
---|
| 29 | ylabel('frequency'); |
---|
| 30 | end |
---|
| 31 | |
---|
| 32 | |
---|
Note: See
TracBrowser
for help on using the repository browser.