Sinewave with log frequency - Shows the wrong frequency content

조회 수: 30 (최근 30일)
Djamil Boulahbal
Djamil Boulahbal 2024년 10월 24일 0:28
댓글: Djamil Boulahbal 2024년 11월 5일 16:31
I'm struggling with a rather basic problem. I create a sinewave with a continuously increasing frequency:
NPTS=500000;
A=(log(50)-log(7))/450;
time = linspace(0,450,NPTS)';
freq = 7*exp(A*time); % The frequency varies from 7 to 50 Hz
Y = sin(2*pi*freq.*time);
Then, when I do an FFT vs. Time of the Y trace, I find that the highest frequency in the signal is close to 150 Hz.
What am I missing here?

채택된 답변

Mathieu NOE
Mathieu NOE 2024년 11월 5일 12:34
hello
you have to compute the angle increment vs time then take the sine of that angle (or, in other words, do the integral of the time varying frequency and then take the sine of that angle )
NPTS=500000;
t_final = 450;
A=(log(50)-log(7))/t_final;
time = linspace(0,t_final,NPTS)';
dt = mean(diff(time));
fs = 1/dt
fs = 1.1111e+03
freq = 7*exp(A*time); % The frequency varies from 7 to 50 Hz
freq(1)
ans = 7
freq(end)
ans = 50
ang = cumsum(2*pi*freq)*dt; % integral of the time varying frequency
Y = sin(ang);
% spectrogram plot
nfft = 1000;
overlap = 0.75; % 75% overlap
spectrogram(Y,hanning(nfft),round(overlap*nfft),nfft,fs,'yaxis')
ylim([0 100])
  댓글 수: 3
Mathieu NOE
Mathieu NOE 2024년 11월 5일 15:54
hello again
yes this is the usual remark when someone tries to generate variable frequency signals (sweeps)
always remember you are dealing with variable frequency and what you want at the end is the sine of an angle (not a frequency)
if your frequency is steady , you can write Y = sin(2*pi*freq.*time);
but if you have a variable frequency, start with the equation that describes how this frequency varies , multiply by 2*pi to convert to pulsation and then time integrate to get the angle
Djamil Boulahbal
Djamil Boulahbal 2024년 11월 5일 16:31
Ok, thank you very much for the explanation.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by