How to plot simple fft of a shifted time series?
1 view (last 30 days)
Show older comments
I am trying to understand basic fft functions of a shifted time series and my graphs are not appearing as I expect them to:
dt = 0.01; % time interval N_ts = 256; % number of time data Td_ts = 2.*(N_ts-1)*dt; % duration t_ts = 0:dt:Td_ts; % define time axis x_ts = zeros(1, length(t_ts)); %Initialize x_ts2 = zeros(1, length(t_ts)); %Initialize t0 = 100; t1 = 156; x_ts(t0)= 1/dt; % time shift of x(t+t0) x_ts2(t1) = 1/dt; % time shift of x(t-t0)
nfft_ts = 511; % Length of FFT X2_ts = fft(x_ts2,nfft_ts)*dt; % Take fft, padding with zeros so that Length(x) is equal to nfft
amp2 = abs(X2_ts); % Take the magnitude of fft of x phase2 = angle(X2_ts); % Take angle
figure(5); plot(t_ts,X2_ts); title('Built-In FFT'); xlabel('Time (s)'); ylabel('X(t)');
0 Comments
Answers (0)
See Also
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!