help-octave
[Top][All Lists]
Advanced

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

Re: Placing 'end' (index) in a variable


From: John W. Eaton
Subject: Re: Placing 'end' (index) in a variable
Date: Tue, 27 Apr 2010 15:30:52 -0400

On 27-Apr-2010, Judd Storrs wrote:

| 2010/4/27 Carn  Draug <address@hidden>:
| > if (interval)
| >  final = input;
| > else
| >  final = end;
| > endif
| 
| How about:
| 
| final = length(data):

The length function is a bit strange because for non-empty arguments,
it returns the size of the largest dimension, not the overall length.
For empty arguments, it returns 0.  This odd behavior is inherited
from Matlab and is required for compatibility.

Instead of using length, I'd recommend using size to get the size of a
specific dimension, or numel for the overall number of elements.

jwe


reply via email to

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