[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Creating a varargin-like object
From: |
Edward C. Jones |
Subject: |
Re: Creating a varargin-like object |
Date: |
Tue, 21 Feb 2006 14:28:36 -0500 |
User-agent: |
Debian Thunderbird 1.0.7 (X11/20051017) |
Miquel Cabanas wrote:
hi,
On Mon, 2006-02-20 at 00:50 -0500, Edward C. Jones wrote:
I use the Debian package octive2.1 version 1:2.1.72-10.
Debian is great! it's actually so great that it comes with all the
answers to your questions. For that you should have installed the
packages,
octave2.1-htmldoc - HTML documentation on the GNU Octave lang
octave2.1-info - GNU Info documentation on the GNU Octave
You can access the HTML documentation from http://localhost/dwww ,
search for "octave" in the "Debian documentation Menu". Afterwards,
select the "The GNU Octave Manual". You could try and see if the link
below works for you,
http://localhost/cgi-bin/dwww?type=html&location=/usr/share/doc/octave2.1-htmldoc/octave_toc.html
If you want too a printed copy of the manual, install
octave2.1-doc - PDF documentation on the GNU Octave langu
The matlab documentation is much more complete. Search for "Pass
Arguments in a Cell Array", "Passing Variable Numbers of Arguments", and
especially "Replacing Lists of Variables with Cell Arrays":
Replacing Lists of Variables with Cell Arrays
Cell arrays can replace comma-separated lists of MATLAB variables in
* Function input lists
* Function output lists
* Display operations
* Array constructions (square brackets and curly braces)
If you use the colon to index multiple cells in conjunction with the
curly brace notation, MATLAB treats the contents of each cell as a
separate variable. For example, assume you have a cell array T where
each cell contains a separate vector. The expression T{1:5} is
equivalent to a comma-separated list of the vectors in the first five
cells of T.
...
What kind of an object is c{:}? Note the curly brackets.
I c is a cell array, c{:} has the UNDOCUMENTED type "cs-list". This
probably means "comma-separated list". This phrase is used to describe
argument lists and return value lists.
Is there an octave document corresponding to
"http://docs.python.org/ref/ref.html"?
http://localhost/cgi-bin/dwww?type=file&location=/usr/share/doc/octave2.1-htmldoc/octave_8.html
Curlu brackets are not mentioned in Chapter 7.
The octave source code is full of stuff like:
function plot (varargin)
__plt__ ("plot", varargin{:});
Why are the curly brackets used?
To convert varargin to a "comma-separated list".
Suppose I have a collection of strings 'A', 'B', ... What should XXX be in
the following:
XXX = ?????
menu('sometext', XXX)
so that the choices in the menu are 'A', 'B', etc. In other words, how do I
create a varargin-like object from scratch?
function simple(x, y)
x
y
endfunction
function doit()
S = strvcat('abc', 'defg')
printf("isstr(S): %d\n", isstr(S));
C = cellstr(S)
printf("iscell(C): %d\n", iscell(C));
# comma-separated list
CSL = C{:}
whos
simple(CSL);
menu('menu', CSL);
endfunction
From the matlab documentation:
"The command strvcat('Hello','Yes') is the same as ['Hello';'Yes '],
except that strvcat performs the padding automatically."
-------------------------------------------------------------
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
-------------------------------------------------------------