How to recover the original signal using ifft
20 views (last 30 days)
Show older comments
Hello everyone,
I've written a code to test the ifft function in MATLAB. However, I've noticed that ifft returns the same number of points as fft. I'm aiming to recover the original signal, which had 1000 points along with the time vector, t. How can I achieve this?
Thanks in advance for your help!
clear;clc;close all;
dt=2.5e-9;
f = 10e6;
Nfft=8*4096;
t = (0:1000-1)*dt;
sinal = sin(2*pi*f*t);
figure(1)
plot(t,sinal)
%Cálculo da fft
fftsinal=fft(sinal,Nfft);
%Transformada inversa de Fourier
sinal_recuperado = real(ifft(fftsinal,Nfft));
figure(2)
plot(1:Nfft,sinal_recuperado);
1 Comment
Accepted Answer
Hassaan
on 11 May 2024
clear; clc; close all;
% Time step
dt = 2.5e-9;
% Frequency of the sine wave
f = 10e6;
% Number of points in the original signal
N = 1000;
% Time vector
t = (0:N-1) * dt;
% Original signal
sinal = sin(2*pi*f*t);
% Plot the original signal
figure(1)
plot(t, sinal)
title('Original Signal')
xlabel('Time (s)')
ylabel('Amplitude')
% Compute the FFT of the original signal
fftsinal = fft(sinal);
% Compute the IFFT to recover the signal
sinal_recuperado = real(ifft(fftsinal));
% Plot the recovered signal
figure(2)
plot(t, sinal_recuperado)
title('Recovered Signal')
xlabel('Time (s)')
ylabel('Amplitude')
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Professional Interests
- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
Feel free to contact me.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!