From: William P. Y. H <wil...@ya...> - 2005-11-12 07:11:05
|
I saw this here: http://www.octave.org/octave-lists/archive/bug-octave.2005/msg00730.html > I wrote it like this: > > if (nargin == 1) > retval = (ismatrix (x) && ! isempty (x) && prod (size (x)) == length (x)); > else > usage ("isvector (x)"); > endif > > Thanks, > > jwe But wouldn't prod(size(x)) overflow? Would this be better: function retval = isvector (x) if (nargin != 1) usage("isvector (x)"); endif retval = 0; if ismatrix(x) s_x = size(x); if (s_x > 0) f_sx1 = find(s_x-1); if (isempty(f_sx1) || (length(f_sx1) == 1)) retval = 1; endif endif endif endfunction William Poetra Yoga Hadisoeseno __________________________________ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs |