I would like to see the spectrogram of x=cos(-250*pi*t^2) for 0<t<2s. How do I plot the spectrogram ( f on y axis, time on x axis)?t = [0,0.1,2]; % Intervall for t y = cos(-2

4 views (last 30 days)
I need a simple code to plot the spectrogram of sinusoids as f over time.
So far, my code looks like this:
t = [0,0.1,2]; % Intervall for t
y = cos(-250 * pi * t.^2); % the signal
spectrogram(y,t)
But the spectrogram is strange.
Which parameters do I need to add or change?

Accepted Answer

Star Strider
Star Strider on 17 Nov 2021
The frequency of the sine curve is 125 Hz, however the sampling frequency of ‘t’ is 10 Hz. This leads to asliasing and unfortunate results. Increase the sampling frequency to 1 kHz and the result appears to be more appropriate —
t = [0:0.001:2]; % Intervall for t
y = cos(-250 * pi * t.^2 ); % the signal
spectrogram(y,t)
colormap(turbo)
I also changed the colormap to make the differences easier to see.
.

More Answers (1)

Julia-Alexandra Giesbrecht
Thank you!! When t = [0:0.0005:2] it looks like i want it to. :)

Categories

Find more on Time-Frequency Analysis in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!