필터 지우기
필터 지우기

complex ifft output for hermitian input

조회 수: 4 (최근 30일)
Md. Al-Imran Abir
Md. Al-Imran Abir 2022년 11월 19일
댓글: Md. Al-Imran Abir 2022년 11월 19일
I have some S11 data (complex) from a simulation and I want to find the corresponding time response. The values are for positive frequencies (5-15 GHz). So, I added conjugates at negative frequencies and padded zeros for frequencies in between. So, I expected the output of the MATLAB ifft to give a real response but got complex values with significat imaginary part. I have added my code and the data here. Can you point at what I am doing wrong?
clc
clear
close all
%% Read values from the file
s11 = readmatrix("Rect_sheet_4.csv");
posFreq = s11(:, 1) * 1e9; %positive frequencies
posVal = s11(:, 2);
%% Conjugates at negative frequencies
negFreq = -flip(posFreq);
negVal = conj(flip(posVal));
%% Adding zeros in between
step = posFreq(2) - posFreq(1);
zeroFreq = (negFreq(end)+step : step : posFreq(1)-step)';
zeroVal = zeros(length(zeroFreq), 1);
%% Merging all frequencies
val = [negVal; zeroVal; posVal];
freq = [negFreq; zeroFreq; posFreq];
%% Plot S11
figure
subplot(2, 1, 1)
plot(freq, real(val), '-.')
title('Real S11')
subplot(2, 1, 2)
plot(freq, imag(val), '-.')
title('Imaginary S11')
%% IFFT
timeResp = ifftshift(ifft(val));
fs = freq(end)-freq(1);
ts = 1/fs;
n = length(freq);
t = (0:n-1)*ts;
%% Plot time response
figure
plot(t, real(timeResp))
title('Real of time resp')
figure
plot(t, imag(timeResp))
title('Imag of time resp')

채택된 답변

Paul
Paul 2022년 11월 19일
Hi Md.
I didn't inspect the whole code, but did notice that the calcuation of timeResp seemed to have the ifft/ifftshift operations in the wrong order. Is the result below closer to what you expect?
clc
clear
close all
%% Read values from the file
s11 = readmatrix("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1199773/Rect_sheet_4.csv");
posFreq = s11(:, 1) * 1e9; %positive frequencies
posVal = s11(:, 2);
%% Conjugates at negative frequencies
negFreq = -flip(posFreq);
negVal = conj(flip(posVal));
%% Adding zeros in between
step = posFreq(2) - posFreq(1);
zeroFreq = (negFreq(end)+step : step : posFreq(1)-step)';
zeroVal = zeros(length(zeroFreq), 1);
%% Merging all frequencies
val = [negVal; zeroVal; posVal];
freq = [negFreq; zeroFreq; posFreq];
%% IFFT
% timeResp = ifftshift(ifft(val));
timeResp = ifft(ifftshift(val));
fs = freq(end)-freq(1);
ts = 1/fs;
n = length(freq);
t = (0:n-1)*ts;
%% Plot time response
figure
plot(t, real(timeResp))
title('Real of time resp')
figure
plot(t, imag(timeResp))
title('Imag of time resp'

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Hilbert and Walsh-Hadamard Transforms에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by