MATLAB Code
clc;
clear all;
close all;
fs = 1000; % Sampling frequency
dt = 1/fs; % Sampling period
L = 1500; % Length of signal
t=( (0:L-1)-ceil((L-1)/2) )*dt ; % Time vector
x = 0.7*sin(2*pi*400*t);
[X,freq]=continuousFTsamples(x,dt);
tiledlayout(1,2)
nexttile
plot(t,x); axis square; xlabel 'Time (sec)'; ylabel 'x(t)'
nexttile
plot(freq,abs(X)); axis square; xlabel 'Freq. (Hz)'; ylabel 'X(f)')
function [X,freq]=continuousFTsamples(x,dt,varargin)
X=fftshift( fft( ifftshift(x), varargin{:} ) )*dt;
L=numel(X);
df=1/L/dt;
freq=( (0:L-1)-ceil((L-1)/2) )*df;
end
clear all;
close all;
fs = 1000; % Sampling frequency
dt = 1/fs; % Sampling period
L = 1500; % Length of signal
t=( (0:L-1)-ceil((L-1)/2) )*dt ; % Time vector
x = 0.7*sin(2*pi*400*t);
[X,freq]=continuousFTsamples(x,dt);
tiledlayout(1,2)
nexttile
plot(t,x); axis square; xlabel 'Time (sec)'; ylabel 'x(t)'
nexttile
plot(freq,abs(X)); axis square; xlabel 'Freq. (Hz)'; ylabel 'X(f)')
function [X,freq]=continuousFTsamples(x,dt,varargin)
X=fftshift( fft( ifftshift(x), varargin{:} ) )*dt;
L=numel(X);
df=1/L/dt;
freq=( (0:L-1)-ceil((L-1)/2) )*df;
end
Output
How long will the above process will work properly
Restrictions
As here sampling frequency is equal to 1000. So the highest frequency available in the message signal must be equal or below half of the sampling frequency.