FFT analyzing of signal and signal reconstrution. (I want to reconstruct by suming a*sin(w*t-phi)

조회 수: 4 (최근 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)

답변 (1개)

Daniel kiracofe
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().

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by