Inverse FFT of a matrix
Show older comments
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?
Answers (1)
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 Comments
Sulaymon Eshkabilov
on 18 Feb 2024
Should you need more elaborations, post your sample data.
Ganesh Prasad
on 18 Feb 2024
Paul
on 18 Feb 2024
Please show all of the code, in particular the code that includes the plot command that made that plot.
Ganesh Prasad
on 19 Feb 2024
Ganesh Prasad
on 19 Feb 2024
Paul
on 19 Feb 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
on 19 Feb 2024
Paul
on 19 Feb 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
on 20 Feb 2024
Paul
on 21 Feb 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
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!