Inverse FFT of a matrix

5 vues (au cours des 30 derniers jours)
Ganesh Prasad
Ganesh Prasad le 18 Fév 2024
Commenté : Paul le 21 Fév 2024
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?

Réponses (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 18 Fév 2024
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 commentaires
Ganesh Prasad
Ganesh Prasad le 20 Fév 2024
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 le 21 Fév 2024
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

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by