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 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Julia-Alexandra Giesbrecht
el 17 de Nov. de 2021
Comentada: Star Strider
el 18 de Nov. de 2021
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?
0 comentarios
Respuesta aceptada
Star Strider
el 17 de Nov. de 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.
.
0 comentarios
Más respuestas (1)
Julia-Alexandra Giesbrecht
el 18 de Nov. de 2021
1 comentario
Star Strider
el 18 de Nov. de 2021
As always, my pleasure!
The important change is providing the high sampling rate (2000 Hz) with that ‘t’ vector.
.
Ver también
Categorías
Más información sobre Time-Frequency Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!