How to recover the original signal using ifft

12 次查看(过去 30 天)
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);

采纳的回答

Hassaan
Hassaan 2024-5-11
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 个)

类别

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