Is this a bug?

1 view (last 30 days)
sa
sa on 8 Apr 2012
Is this a bug?
clear all;
figure(1);
stem([1 2],[pi 2]);
(the pi entry does not appear in the plot) Thanks
  3 Comments
sa
sa on 8 Apr 2012
I am using 2011b on 64 bit computer (though this is probably irrelevant)
sa
sa on 8 Apr 2012
If you see the pi entry at x=1 try rescaling the stem window, the pi seems to disappear randomly

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 8 Apr 2012
No, it's doing what it should. They both appear, maybe you just don't see it. Try this code:
figure;
stem([1 2],[pi 2], 'LineWidth', 3);
grid on;
xlim([0 4]);
You'll see that there is a stem at both x=1 with height 3.141 and at x=2 with height 2. Of course there is no stem at x=pi since pi was the y value not the x value - was that what you were expecting? The x values are the first array and the y are the second, like [x1 x2 x3], [y1, y2, y3]. It is not [x1, y1], [x2, y2], [x3, y3].
  4 Comments
Image Analyst
Image Analyst on 8 Apr 2012
Perhaps it is a bug. The stem at x=1, y=pi seems to come and go depending on the size of the figure. As I drag the figure wider it will randomly appear and disappear depending on what size I set the figure to. Maybe it's a subsampling/aliasing issue with the display resolution. I can't get the behavior when the left stem is not lying on the Y axis (like you get when you widen the x axis with xlim so that the left edge is at x=0 and not x=1).
sa
sa on 8 Apr 2012
When I replace Pi with integers the scaling does nothing.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!