필터 지우기
필터 지우기

Inverse FFT of a matrix

조회 수: 1 (최근 30일)
Ganesh Prasad
Ganesh Prasad 2024년 2월 18일
댓글: Paul 2024년 2월 21일
Hello
I am trying to get the ifft of a S parameter matrix having frequency in the first column and the data in the second column.The code is below:
sp=sparameters('2Port.s2p');
freq=sp.Frequencies;
s=sp.Parameters;
s21=s(2,1,:);
%take s21 seperately
for i = 1:length(freq)
new_s21(i)=s21(:,:,i)
end;
s21_t=transpose(new_s21);
%ifft of S21
impulse_response1=ifft(s21_t);
I am getting a plot of IFFT with the x -axis having values from 0 to 1800 which I am not able to understand.Is the x-axis in seconds?
How to get the ifft() for the freq data that i have?

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2024년 2월 18일
Just looking at your attached figure, it is clear along x axis is time. inverse FFT gives back time domain data from freq domain data.
open('ifft.fig')
  댓글 수: 10
Ganesh Prasad
Ganesh Prasad 2024년 2월 20일
Thanks a lot Paul for taking the time and explaining the solution in detail.
I am passing an input signal through an S matrix and observing the output signal in ADS simulation.
I am trying the same in MATLAB without using the rationalfit or using s2tf functions.
I see that the convolution output of MATLAB is not matching the ADS output.Not sure what the problem is.
The code is below:
sp=sparameters('C:\Users\PrasadNGanes\Desktop\snp\QVR_MX0100A_InfMode_SldrInFlat_Zin_2Port.s2p');
freq=sp.Frequencies;
s=sp.Parameters;
%Seperate S21 from S matrix
s21=s(2,1,:);
for i = 1:length(freq)
new_s21(i)=s21(:,:,i)
end
s21_t=transpose(new_s21);%%%%%%%%%%RI format
%Impulse response of S21
impulse_response1=ifft(s21_t);
Ts=0.167e-3;%as the delta freq is 6kHz in S2P file
N=numel(impulse_response1);
tvec=(0:(N-1))*Ts;
figure;
plot(tvec,abs(impulse_response1));
title('impulse response');
%%%%%%%%%%Convolution%%%%%%%%%%%%%%%%%%
%read input signal from xls
data=xlsread('C:\Users\PrasadNGanes\Desktop\probe.xlsx');
time1=data(:,1);
input=data(:,2);
%convolve input with the impulse response
convolution_result=conv(input,abs(impulse_response1));
convolution_time=linspace(min(time1)+min(tvec),max(time1)+max(tvec),length(convolution_result));
figure;
plot(convolution_time,convolution_result);
title('convolution output');
%read output file from ADS simulation and plot the output and input
data2=xlsread('C:\Users\PrasadNGanes\Desktop\probe_output.xlsx');
pr_out_time1=data(:,1);
pr_out_input=data(:,2);
figure;
plot(time1,input,'r');
title('input');
figure;
plot(pr_out_time1,pr_out_input,'b');
title('probe output');
I have attached the plots for reference.Could you help me in debugging the problem in the code.
Paul
Paul 2024년 2월 21일
Sorry, I don't have enought insight into how this is all suppsosed to work. I assume that the variables input and impulse_response1 have the same sampling period. Why is the convolution using abs(impulse_response1), i.e., why the abs? One other issue that you may want to look into is that you might need to use fftsfhift to get the impulse response:
impulse_response1=ifft(s21_t);
and then the corresponding tvec would be:
tvec = ((0:N-1)-floor(N/2))*Ts

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by