Question using IFFT, try to transform continuous 1 from frequency in time domain
Show older comments
Hey. I have a frequency response of a system. I want to see this frequency response in the time domain, so I want to transform it into this. Here for I want to create a program, where I enter a one-sided frequency spectrum, so the frequency vector (freq) with the associated amplitudes (y_f).
I have now created this program. If I want to transform a pulse (e.g. at 10 kHz, see 1. Example), the time axis and amplitude in the time domain look good.
However, if I try to transform a continuous 1 signal, the result does not look correct anymore. The time axis should be correct, but unfortunately the amplitude is not. As far as I know, the amplitude should be 1 at t = 0, but it has the value 150.000 (which is half of my vector length).
The problem wonders me, since 1. example seems to work.
Does anyone know where my problem is?
Thanks a lot!
Complete program follows:
clear
% signal input for one-sided spectrum
freq = 0:(10/3):500e3; % preset frequency points
%%%%% 1. Example: dirac impuls at 10 kHz (expceting cos with T = 100 us)
% for k = 1:length(freq) % filling y_f with zeros
% y_f(k) = 0;
% end
% y_f(3001)=1; % set sample 3001 (10 kHz) to 1
% figure(1)
% plot(freq,y_f)
%%%%%
%%%%% 2. Example: continuous 1 (expecting dirac at t = 0)
for k = 1:length(freq) % filling y_f with zeros
y_f(k) = 1;
end
figure(1)
plot(freq,y_f)
%%%%%
%%% IFFT
y_fQ1 = y_f; % 1. Quadrant
y_fQ2 = conj(y_f); % 2. Quadrant Complex conjugate
y_fQ2 = fliplr(y_fQ2(2:end));% Flip array left to right
y_f2 = [y_fQ2,y_fQ1(1)*1 ,y_fQ1(2:end)]; % two-sided frequency
y_f2 = y_f2 * 0.5 * length(y_f2); % Adjust amplitude for ifft
y_f2 = ifftshift(y_f2); % shift spectrum for ifft ...i.I.i... --> I.i......i.
y_t = ifft(y_f2,'symmetric');
delta_f = freq(end)-freq(end-1); % Frequency resolution
L = 2*length(freq)-1;
Fs = freq(end)*2; % Sampling frequency
delta_t = 1/Fs; % time resolution
t = 0 : delta_t : (L-1)*delta_t; %% create time vector
figure(3)
plot(t, y_t) % plot result
Accepted Answer
More Answers (0)
Categories
Find more on z-transforms 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!