help-octave
[Top][All Lists]
Advanced

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

Re: Too Basic: Ending limit of array


From: Isak Delberth Davids
Subject: Re: Too Basic: Ending limit of array
Date: Mon, 6 Dec 2010 12:29:20 +0200

On 6 December 2010 12:22, c. <address@hidden> wrote:

On 6 Dec 2010, at 09:16, Isak Delberth Davids wrote:

> Hi octavians,
>
> This is so basic that I could not get search words for googling, and similarly it took me 7.9 minutes to get a title for it. Embarrassed!
>
> I thought the following must give me "error: subscript indices must be either positive integers or logicals."
> A = 1:7.9
> but it gives the same result as
> A = 1:7.1
> so that it looks like
> A = 1:floor(7.9)
> I think 7.9 and 7.1 are not "positive integers".

Actually

A = 1:7.1

is (almost [*]) equivalent to:

i    = 1;
A(i) = 1;

while A(i)+1 < 7.1
 A(i++) = A(i) + 1;
endwhile

so A IS all positive integers.

>> 1:7.9
ans =

  1   2   3   4   5   6   7

if you try

A=1.1:7

you will not get positive integers. You will only get the error you expected if you use A as an index.

> Sorry for taking you so low down on this innocent Monday's morning!
>
> Isak

HTH,
c.



[*] It would have been exactly equivalent if you had written:
A = [1:7.1]


Good stuff!
 
IDD


reply via email to

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