I would like to know whether it is possible to customize the plot generated by MATLAB's spectrogram
function in such a way that its x-axis does not represent the time but another physical signal y2
captured simultaneously with the input signal y1
(used for computing the spectrogram). Therefore, it can be assumed that y1
and y2
have the same timestamps as x-axis as in the following example.
N = 1024;
n = 0:N-1;
w0 = 2*pi;
y1 = sin(w0*n);
y2 = n;
spectrogram(y1,'yaxis');
To control the scale of the axes arbitrarily, you could manually plot the spectrogram using
imagesc
. Here's how:Note that I have made two minor changes to your code:
w0
from2*pi
to2*pi/10
, because the former results iny1
being all zeros.y2
to be something else than1:N
, which is spectrogram default.I should also point out that the built-in
spectrogram
plot does let you control the axes scale in a variety of ways, including specifying the sample rate.