FFT analyzing of signal and signal reconstrution. (I want to reconstruct by suming a*sin(w*t-phi)
Afficher commentaires plus anciens
% I built a square wave simply by writing a file from 0-0.0128 for time and amplitude of 1 and -1. after analyzing with the fft %fuction. I want to reconstruct the Sqare wave by summing, not the IFFT function. The following code is how I did it. However, there %seems to be a missing cos(x) component. What am I missing?
figure(20)
plot(timesimple,simpleamp)
Simple=fft(simpleamp);
MagSimple=abs(Simple);
PhaseS=angle(Simple);
figure(21)
plot(MagSimple)
title('Square Wave FFT')
dsf=1/(.0001*64);
SimpFreq=(timesimple/.0001)*dsf;
ResultS=0;
for loop=1:64
a=MagSimple(loop)/64;
b=loop*78.1250;
c=PhaseS(loop);
ResultS=ResultS+a*sin(2*pi*b*timesimple+c);
end
figure(22) plot(ResultS)
Réponses (1)
Daniel kiracofe
le 17 Août 2014
0 votes
You forgot the negative frequencies. You didn't state explicitly the definition of simpleamp, but I think length(Simple) should be 128. In this case loop need to run from 1:128, and SimpFreq should include both the positive and negative frequencies. You might look at fftshift().
Catégories
En savoir plus sur Fast Fourier Transforms dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!