I have frequency data from a VNA. I am trying to convert to time domain, and I can't figure out why I am getting complex valued time domain data. This is for ISAR measurements, and I can't get passed this simple step.
ifft_points = length(frequency)*1;
% S11 time domain
for i = 1:1:s_param_number
temp_data = data(:,i);
data_flip = conj(flipud(temp_data(2:end))); % complex conjugate
data_total = [data_flip; data(:,i)];
data_ifft = ifft(temp_data, ifft_points);
S_param_time(:,i) = (ifftshift(abs(data_ifft)));
end
% Create the Time Vector
BW = frequency(end) - frequency(1); % Bandwidth of the frequency data
dt = 1/BW; % Time step
start_time = -length(S_param_time(:,1))/2*dt; % Start time of the Time Domain Vector
end_time = length(S_param_time(:,1))/2*dt-dt; % End time of the Time Domain Vector
time_vector = start_time: dt: end_time; % Time Domain Vector
In the above code, the variable data
is a complex valued S-Parameter measurement. The variable data_ifft
is always complex.
My thoughts on this:
- I take my data and flip it and conjugate it
- I append the flipped data to the beginning of the original data
- Take the IFFT and specify the points to be the original size
- Do the IFFT shift.
I don't think the the symmetric
tag is the way to go because that is meant for data that is already very near to being complex symmetric.
EDIT/UPDATE
Ok, so I updated a few things. I am taking measurements on a VNA from 500MHz to 8GHz with 48001 points, this gives a delta_f of 156250Hz
- I take my raw S21 data (real/imaginary) and zero pad from DC to 3200 points
- Make a copy of raw S21 data from 2:end and flip and conjugate
- I append the flipped data to the beginning of the original data. This should give a full FFT to then take the IFFT and IFFT shift.
points = length(freq_data); % Number of points in raw data
df = (freq_data(end) - freq_data(1))/(points-1); % Frequency step
fs = 2^17*df; % Sampling frequency
lower_points = floor(freq_data(1)/df); % Number of lower points to zeropad
upper_points = (fs)/df - points - lower_points; %Number of upper points to zero pad
for i = 1:1:(2^17)
freq_total_FFT(i) = (i-1)*df; % Create the total frequency vector
end
freq_total_FFT = freq_total_FFT';
S21_copy= [zeros(lower_points,1); S21_raw; zeros(upper_points,1)];
S21_flip = conj(flipud(S21_copy(2:end)));
S21_full_FFT = [S21_copy; S21_flip ];
S21_time = ifftshift(ifft(S21_full_FFT));
% Create the Time Vector
BW = freq_total_FFT(end) - freq_total_FFT(1); % Bandwidth of the frequency data
dt = 1/BW; % Time step
start_time = -ceil(length(S21_time (:,1))/2)/2*dt; % Start time of the Time Domain Vector
end_time = ceil(length(S21_time (:,1))/2)/2*dt-dt; % End time of the Time Domain Vector
time_vector = start_time: dt/2: end_time; % Time Domain Vector
- After taking the IFFT, I use a kaiser window and filter
filter_order = 10; beta = 6;
Fsample = freq_total_FFT(end)*1e-9; Fc1 = .8; Fc2 = 5.2;
flag = 'scale';
win = kaiser(filter_order +1, beta); % calculate the kaiser window
passband = [Fc1 Fc2]/(Fsample/2); % bandpass passband
b = fir1(order, passband, 'bandpass', win, flag);
hd = dsp.FIRFilter('Numerator', b);
filtered_data = filtfilt(hd.Numerator, 1, S21_time);
The plot shows time data pulled directly from VNA (BLACK), IFFT unfiltered (BLUE), and IFFT filtered (RED). The green is the area of interest which I will time gate, but I am still having issues getting my time results to look similar to the VNA