How does command STEM work for complex numbers?
6 views (last 30 days)
Show older comments
Ques: How does command STEM work for complex numbers?
Description: I have taken a signal, and using the matlab command i found its fft. The fft results will have same no. of points as it is in the signal. Most of the fft points will be complex no. When i do the plot of the fft signal, it will display on the graph in discrete format.
I tried this:
a=[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0]
f=fft(a);
disp(f);
figure, stem(a);
figure, stem(f)
imtool(f,'InitialMagnification','fit');
Query: When i see the elements of 'f' its something like this
12.0000
-6.0047 + 0.9511i
-1.8090 + 0.5878i
1.1536 - 0.5878i
1.3090 - 0.9511i
0
-0.6910 + 0.9511i
-0.2995 + 0.5878i
0.1910 - 0.5878i
0.1506 - 0.9511i
0
0.1506 + 0.9511i
0.1910 + 0.5878i
-0.2995 - 0.5878i
-0.6910 - 0.9511i
0
1.3090 + 0.9511i
1.1536 + 0.5878i
-1.8090 - 0.5878i
-6.0047 - 0.9511i
What i noticed is that, the real part is not considered while plotting, but its only the imaginary part which is considered for plotting, and that too its reversed, it means the positive values are shown below x axis and negative values are shown above x axis.
Any clarification? I hope that i'm doing the right thing, and looking into the right values.
2 Comments
Matt J
on 30 Jan 2014
I recommend modifying your Question's title. There is nothing here that is tied to FFTs. Your question is really about how the stem() command processes complex-valued data.
Answers (2)
Matt J
on 30 Jan 2014
Edited: Matt J
on 30 Jan 2014
It is interesting that the real part is ignored by STEM. That is undocumented behavior, as far as I can see. I do not see the flipping of the sign that you mention. Negative imaginary values for me appear below the x-axis, as they should.
I hope that i'm doing the right thing, and looking into the right values.
It's not clear what behavior you expected from STEM for complex-valued input, since none is documented.
0 Comments
Jos (10584)
on 30 Jan 2014
Edited: Jos (10584)
on 30 Jan 2014
STEM uses PLOT to make its lines. The documentation of PLOT is clear on complex numbers:
PLOT(Y) plots the columns of Y versus their index. If Y is complex, PLOT(Y) is equivalent to PLOT(real(Y),imag(Y)). In all other uses of PLOT, the imaginary part is ignored.
Try to use STEM with an X argument to plot the real part of Y, or get the part of Y you are interested in using stem(real(Y)) (or stem(imag(Y))).
0 Comments
See Also
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!