How does command STEM work for complex numbers?
9 次查看(过去 30 天)
显示 更早的评论
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 个评论
Matt J
2014-1-30
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.
回答(2 个)
Matt J
2014-1-30
编辑:Matt J
2014-1-30
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 个评论
Jos (10584)
2014-1-30
编辑:Jos (10584)
2014-1-30
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 个评论
另请参阅
类别
在 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!