FFT analyzing of signal and signal reconstrution. (I want to reconstruct by suming a*sin(w*t-phi)
3 次查看(过去 30 天)
显示 更早的评论
% 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)
0 个评论
回答(1 个)
Daniel kiracofe
2014-8-17
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().
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!