From bug-request at octave dot org Wed Apr 5 14:43:03 2006 Subject: Re: Plot should be able to handle empty vector inputs From: Quentin Spencer To: "John W. Eaton" CC: octave bug mailing list Date: Wed, 05 Apr 2006 14:34:31 -0500 John W. Eaton wrote: > On 5-Apr-2006, Quentin Spencer wrote: > > | In Matlab, it is possible to call the plot function with empty data. > | This is an error > | >> plot([]) > | ??? Error using ==> plot > | Vectors must be the same lengths. > | > | However, this is acceptable. > | >> plot([],[]) > | > | > | In octave, I get the following error: > | oct 1> plot([],[]) > | error: __plt2__: invalid data for plotting > | error: evaluating if command near line 48, column 3 > | error: called from `__plt2__' in file > | `/usr/share/octave/2.9.4/m/plot/__plt2__.m' > | error: evaluating if command near line 58, column 4 > | error: evaluating if command near line 56, column 2 > | error: evaluating if command near line 55, column 7 > | error: evaluating while command near line 44, column 5 > | error: evaluating if command near line 34, column 3 > | error: called from `__plt__' in file > | `/usr/share/octave/2.9.4/m/plot/__plt__.m' > | error: called from `plot' in file `/usr/share/octave/2.9.4/m/plot/plot.m' > | > | Supporting this behavior is useful because I have a situation where I'm > | plotting several vectors, and one pair of them may be empty, but I don't > | know in advance without extra code to check for it. As you can see, this > | is version 2.9.4, but looking at CVS, it looks like this hasn't changed > | since then. > > kHow about the following change. I think it does what you want, but > I've not done a lot of testing. > > | I might be able to write a patch for this, but I don't have > | time right now--maybe later if I'm the first one to get to it. > > Oops, sorry. Well, instead of a patch, can you at do some testing of > the one below? > I just tried it in the application that was breaking for me before and it worked exactly as expected. Thanks. -Quentin ------------------------------------------------------------- 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 -------------------------------------------------------------