octave-maintainers
[Top][All Lists]
Advanced

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

'end' odds & ends


From: Daniel J Sebald
Subject: 'end' odds & ends
Date: Sat, 29 Jan 2005 15:33:12 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020

There are a few details about using 'end' as the index of a matrix or vector...

The command-line documentation does not mention this use of 'end'. That is, it only says

-----------------
*** end:

Mark the end of any for, if, do, while, or function block.
------------------

Also, it would be good to include comments about 'end' under the 'help -i' documentation for section 10.1 Index Expressions. Furthermore, better organizing the text under 10.1 Index Expressions might make it more clear. There is a discussion of how to generate a vector and matrix using indices, but then after that is a note to not do such a thing.

-----------
   Similarly, indexing a scalar with two vectors of ones can be used to
create a matrix.  For example the following statements

    a = 13;
    a ([1, 1], [1, 1, 1])

create a 2 by 3 matrix with all elements equal to 13.

  This is an obscure notation and should be avoided.  It is better to
use the function `ones' to generate a matrix of the appropriate size
whose elements are all one, and then to scale it to produce the desired
result.  *Note Special Utility Matrices::.
---------

Why explain it if it isn't to be recommended? Does the note apply to just generating matrices that way, but vectors are OK? If so, there shouldn't be a new paragraph because that would mean it's talking about something new to come. Also, perhaps put the note up front to give it emphasis. (As it is now, a new user wouldn't read as far as the note and think "oh, that's how I create a matrix".) Now, the second detail about 'end'. The emacs lisp file doesn't recognize 'end' except as the end of a conditional or loop. Therefore, it claims a mismatch and loses track of indentation. (I know zilch about Lisp.) Anyone familiar with Lisp know if this is an easy fix? Or might there be something tricky about it?

Dan



reply via email to

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