DSPRelated.com
Forums

Stem; hold and replace simultaneously

Started by g_loughnan July 20, 2009
Hi All,

I'm trying to do a stem plot within a MATLAB GUI as follows:

1. Plot one stem (stem1)
2. Plot a second stem (stem2) on the same axes figure
3. Plot a third stem which replaces stem2, but stem1 is retained on the graph
4. Repeat step 3, each stem replacing the previous one, while stem1 is retained on the graph

I think I have managed to hack something together that half works. It's something like:

%callback function to plot stem1
case 'plotStem1'

xP; %arbitrary value
y0; %arbitrary value
hold on
stem(x,y)

%callback function to plot subsequent stems
case 'plotSubsqntStems'

n=0;
while n==0;
[x,y] = ginput(1);

hold off
stem(x,y,'EraseMode', 'xor')
end

So I press a button to plot stem1, then when I click anywhere on the graph, a stem is plotted at that point and each subsequent stem replaces the previous one using the 'xor' eraser. What happens is though, the figure zooms right in on each stem when I click on the screen. So I can't see if stem1 is retained, and even if it is, I don't want to zoom in on the figure at all.
Could anyone suggest some way of getting around this?

Thanks,
Ger.