help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem with plot / hold


From: Robert A. Macy
Subject: Re: problem with plot / hold
Date: Fri, 26 May 2006 04:07:30 -0700

Matthias,

Since watching your emails, I've worked up enough courage
to explore subplot() using
    octave 2.1.50a on Win98

I went through similar sequences for a test...

subplot top, plot 1
subplot bottome, plot 2

then using the same variable names I tried to overwrite the
top plot with some slight changes...
>> subplot(2,1,1);hold on;plot(x2);hold off;
...wow! did I get what seems like strange results!

For me I ended up sometimes with 3 plots on the top.  
There was the original top, a copy of the bottom, and the
new one x2.  

Didn't seem right at all.  Not only that but as I kept
trying various things the plots would flash through the
history of everything I'd done, finally settling on
something unwanted.  

Assuming your data comes in as steps with the first set is
impulse and step, my workaround was to simply ...
>> impulse01=impulse;step01=step;
>> subplot(2,1,1);plot(impulse01);
>> subplot(2,1,2);plot(step01);

new data comes in...
>> impulse02=impulse;step02=step;
>> subplot(2,1,1);clearplot;plot(impulse01);hold
on;plot(impulse02);hold off;
>> subplot(2,1,2);clearplot;plot(step01);hold
on;plot(step02);hold off;
...and so on

Since impulse is a vector, you could usea matrix to keep
track...
>> impulsedisplay(1,:)=impulse;stepdisplay(1,:)=step;
and use a small script containing a for loop in the plot

Seems clumsy, but you'll keep a record of each change.

The flashing of every plot ever done is still irritatingly
occurring.  Just tried subplot a few times using my script
and I got at least 14 old plots before the display settled
on the desired ones.  Hmmmm....guess I could add closeplot
first, but that really is a workaround.  

AARRRRGGGG!!!!! just found that if I use closeplot to kill
all the flashing, it breaks my ability to even use subplot
again.  After using closeplot, the command line sequnce
that creates two plots, now flashes the first one [which
should have been on the top] then displays the bottom one
FULL size.  And there's only one plot left.  Somehow I have
permanently changed octave and have to restart it.  

There must be some way to flush out whatever is lined up to
go to those plots.  

                   - Robert -

On Fri, 26 May 2006 10:20:21 +0200
 Matthias Brennwald <address@hidden> wrote:
> > Message: 4
> > Date: Thu, 25 May 2006 13:30:53 +0200
> > From: Javier Arantegui <address@hidden>
> > Subject: Re: problem with plot / hold
> > To: address@hidden
> > Message-ID: <address@hidden>
> > Content-Type: text/plain;  charset="iso-8859-1"
> >
> > Hi,
> >
> > I haven't used Matlab in my life, so I don't know if
> this solution  
> > will work
> > in Matlab.
> >
> > El Jueves, 25 de Mayo de 2006 12:16, Matthias Brennwald
> escribi?:
> >> In Matlab, these commands to exactly what I want. In
> Octave, however,
> >> the second plot contains all three data sets instead
> of only the
> >> third set.
> >
> > The solution is very easy:
> >
> > subplot(2,1,1);     % open up the first plot
> > plot(rand(1,10));   % plot the first data set to the
> first plot
> > hold on             % hold the plot
> > plot(rand(1,10));   % plot the second data to the first
> plot
> >
> > hold off
> >
> > subplot(2,1,2);     % open up the second plot
> > plot(rand(1,10));   % plot the third data set to the
> second plot
> >
> > Javier
> 
> Ok, that does the trick. However, I'm not yet happy... I
> should have  
> modelled my example closer to my real-world problem.
> 
> What I'm trying to do is the following: I analyze a
> loudspeaker  
> system using either Octave or Matlab and a custom sound
> in/out system.
> In a first step, I measure some data and plot this data
> in different  
> ways on different plots (impulse response in one plot and
> step  
> response in the other plot). After looking at these
> plots, I decide  
> to change the speaker in some way, re-measure the data,
> and plot the  
> results for comparison with the first measurement. In
> other words:
> 
> * I measure the impulse response and calculate the step
> response from  
> the impulse response.
> * I plot the impulse response to the first plot, the step
> response to  
> the second plot.
> * After looking at these plots, I change the loudspeaker
> system and  
> re-analyses it.
> * Then, I want to plot the impulse response of the new
> measurement to  
> the first plot, keeping the the impulse response from the
> first  
> measurement for reference.
> * Also, I want to plot the step response of the new
> measurement to  
> the second plot, keeping the the step response from the
> first  
> measurement for reference.
> 
> This can be illustrated by the following code (which does
> exactly  
> what I want with Matlab, but not with Octave):
> 
> t = [0:100]; h1 = sin(t).*exp(-t/5);    % invent some
> fake  
> measurement data of the first measurement ( impulse
> response h1(t) )
> subplot(2,1,1);                         % open up the
> plot for the  
> impulse response
> plot(t,h1);                             % plot the
> impulse response  
> from the first measurement
> hold on                                 % hold the plot
> to allow  
> comparison with future measurement(s)
> subplot(2,1,2);                         % open up the
> plot for the  
> step response
> plot(t,cumsum(h1));                     % plot the step
> response from  
> the first measurement
> hold on                                 % hold the plot
> to allow  
> comparison with future measurement(s)
> 
> h2 = sin(1.2*t).*exp(-t/7);             % invent some
> fake  
> measurement data of the second measurement ( impulse
> response h(t) )
> subplot(2,1,1);                         % go to the plot
> for the  
> impulse response
> plot(t,h2);                             % plot the
> impulse response  
> from the second measurement
> subplot(2,1,2);                         % go to the plot
> for the step  
> response
> plot(t,cumsum(h2));                     % plot the step
> response from  
> the second measurement
> 
> Again: In Matlab, these commands do exactly what I want.
> In Octave,  
> however, the second plot contains more plots than
> intended. Where's  
> my mistake?
> 
> Is there a way to make my code 'universal' such that it
> runs as  
> intended both with Matlab and Octave?
> 
> Matthias


reply via email to

[Prev in Thread] Current Thread [Next in Thread]