|
From: | Matthias Brennwald |
Subject: | Re: problem with plot / hold |
Date: | Fri, 26 May 2006 10:20:21 +0200 |
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 workin 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
[Prev in Thread] | Current Thread | [Next in Thread] |