[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: partial plot
From: |
Miquel Cabanas |
Subject: |
Re: partial plot |
Date: |
Mon, 22 Mar 2004 16:10:35 +0100 |
User-agent: |
Mutt/1.3.28i |
ok, that requieres a bit of octave code to handle the situation
On Fri, Mar 19, 2004 at 02:11:08PM -0600, Pascal A. Dupuis wrote:
>
> In the case of NaN, the value is ignored, and lines are interpolated
> around the missing point. What I would like is to have the line stop
> before the missing value, to emphasize the fact that nothing is available.
>
i think the code below will work, otherwise feel free to modify
and/or improve it to fit your needs. So far I have tested having
NaN at one or both ends, having consecutive NaN, and nothing crashed,
but in some cases x_to_plot and y_to_plot were equal to "[](0x0)",
though nothing wrong happened.
y = [10, -20, NaN, -40, 50, NaN, 70, -80];
x = 1:1:length(y);
## create a vector that will hold the discontinuities,
## i.e. NaN's indices
discontin = find(isnan(y))
if !isnan(y(1))
## first point is a number, pretend there's a NaN at #0
discontin = [0, discontin]
endif
if !isnan(y(length(y)))
## last point is a number, pretend there's a NaN past the end
discontin = [discontin,length(y)+1]
endif
figure();
hold on;
for i=1:length(discontin)-1
## create subvector to plot
x_to_plot = x(discontin(i)+1:discontin(i+1)-1)
y_to_plot = y(discontin(i)+1:discontin(i+1)-1)
## plot data
plot(x_to_plot, y_to_plot, 'o-')
endfor
Briefly, in the above case, discontin = [3 6] in a first instance,
and then discontin = [0 3 6 9] after adding the fake NaN that limit
the edges of y-vector. The plotted subvectors are y(1,2), y(4,5) and
y(7,8).
Hope this helps,
Miquel
--
Miquel E Cabanas ------------------------------------------------------
SeRMN, Universitat Autonoma de Barcelona (address@hidden)
------------------------------------------o-oo--ooo---ooo--oo-o--------
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------