I am using MATLAB and I am trying to find the ifft of a symmetric function, but I keep getting a complex result. I have tried using circshift, but I can't seem to get it figured out.
How can I fix it?
Here is the code:
t = 0:0.001:0.119;
for i = 1:120
comp1(i) = 9.8*cos(2*pi*200*t(i));
comp2(i) = 7.6*cos(2*pi*145*t(i) + 30/57.3);
comp3(i) = 5.4*cos(2*pi*93*t(i) + 70/57.3);
comp4(i) = 3.2*cos(2*pi*58*t(i) + 160/57.3);
comp5(i) = cos(2*pi*35*t(i) + 320/57.3);
YS = comp1 + comp2 + comp3 + comp4 + comp5;
end
Q = 1000/(2*60)*[-59:1:60];
Box = [zeros(1, 40), ones(1, 5), zeros(1, 30), ones(1, 5), zeros(1, 40)];
Box1 = circshift(Box, [0, 60]);
F = ifft(Box1);
(I am not sure what YS
and Q
in your code are for, so I just ignore them).
The transform X
of a real signal x
of length N
has the property that
X(k) = X(N-k)*
for k=1,...,N-1
, where *
is complex conjugate. For a real transform (as in your example) you can just ignore the *
. Note that the indexing goes from 0
to N-1
, so for k=0
the above property is not defined, since the index of the last term is N-1
(there is no X(N)
).
In your case the signal Box
does not have this property, nor does Box1
(check it!). Try for example:
Box = [zeros(1,41),ones(1,5),zeros(1,29),ones(1,5),zeros(1,40)];
This signal does have this property, and its ifft
is indeed real.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.