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?

Respuestas (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 18 de Feb. de 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 comentarios

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 18 de Feb. de 2024
Should you need more elaborations, post your sample data.
Ganesh Prasad
Ganesh Prasad el 18 de Feb. de 2024
What is the unit of the time axis?The plot is from 0 to 2000 but does not convey if it's seconds or millisec or nanoseconds.The impulse response matrix contains ifft values but not the time vector.I need the time vector of the ifft result to them convolve with another input signal. By sample data do you mean the impulse response matrix?
Paul
Paul el 18 de Feb. de 2024
Please show all of the code, in particular the code that includes the plot command that made that plot.
Ganesh Prasad
Ganesh Prasad el 19 de Feb. de 2024
Please see the code below:
sp=sparameters('2port.s2p');
freq=sp.Frequencies;
s=sp.Parameters;
s21=s(2,1,:);
for i = 1:length(freq)
new_s21(i)=s21(:,:,i)
end;
s21_t=transpose(new_s21);
impulse_response1=ifft(s21_t);
figure;
plot(impulse_response1);
title('impulse response');
Please let me know of the changes to be made.
Ganesh Prasad
Ganesh Prasad el 19 de Feb. de 2024
Also,i have used the rationalfit to the s parameter file and then taken the impulse response.The code is below:
sp=sparameters('C:\Users\PrasadNGanes\Desktop\snp\QVR_MX0100A_InfMode_SldrInFlat_Zin_2Port.s2p');
S21=rfparam(sp,2,1);
freq=sp.Frequencies;
fit_data=rationalfit(freq,S21);
[resp,t]=impulse(fit_data,125e-12,2e3);
plot(t,resp);
How can the impulse response taking the ifft(s21) and using the impulse(fit_data) be so different?
Paul
Paul el 19 de Feb. de 2024
This line:
plot(impulse_response1);
is plotting the elements of impulse_response1 agains the index vector 1:N, where N = numel(impulse_response1). If you want to plot against an actual time vector, the command would be
tvec = (0:(N-1))*Ts;
plot(tvec,impulse_response1);
where Ts is the sampling period of the signal.
Ganesh Prasad
Ganesh Prasad el 19 de Feb. de 2024
Thanks Paul for the answer.
I have edited the code as suggested by you.A warning message saying that the imaginary components are ignored during processing is displayed.Why does this happen?
new code:
sp=sparameters('C:\Users\PrasadNGanes\Desktop\snp\QVR_MX0100A_InfMode_SldrInFlat_Zin_2Port.s2p');
freq=sp.Frequencies;
s=sp.Parameters;
S21=rfparam(sp,2,1);
impulse_response1=ifft(S21);
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,impulse_response1);
title('impulse response');
The attached snapshot has the warning message.
Paul
Paul el 19 de Feb. de 2024
That means that impulse_response1 has a non-zero imaginary part. If you're expecting based on physics (or whatever) that impulse_response1 is a real-valued signal, then it's possible that ifft still returns a small imaginary part if S21 is not exactly conjugate symmetric. You can check this by
plot(tvec,real(impulse_response1))
plot(tvec,imag(impulse_response1))
If it looks like the imaginary part is just floating point error based on it's magnitude and you expect it to be exactly zero, then you can just get rid of it
impulse_response1 = real(impulse_response1);
or use the symmetric flag to force ifft to return a real-valued result.
impulse_response1=ifft(S21,'symmetric');
If S21 is, in fact, expected to have a non-negligible imaginary component, then you'll have to plot the real and imaginary parts separately (as shown above) or plot magnitude and phase, or whatever makes sense for your application.
Ganesh Prasad
Ganesh Prasad el 20 de Feb. de 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 el 21 de Feb. de 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

Iniciar sesión para comentar.

Categorías

Más información sobre Fourier Analysis and Filtering en Centro de ayuda y File Exchange.

Preguntada:

el 18 de Feb. de 2024

Comentada:

el 21 de Feb. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by