help-octave
[Top][All Lists]
Advanced

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

Re: Problem creating compiled oct file


From: Carlo de Falco
Subject: Re: Problem creating compiled oct file
Date: Sun, 4 Oct 2009 08:33:28 +0200


On 3 Oct 2009, at 16:47, babelproofreader wrote:


C++ has a much more strict type system, so you can't expect it to work
out types for you at run-time. You need to do something like

 ColumnVector c = args (0).column_vector_value ();
 octave_stdout << c (0) << std::endl;

What syntax would I use to access the individual elements of c?

That's already shown in Søren's example: "c (0)" stands for the first element of c
the example below shows how you would print all elements of c

for (ii = octave_idx_type (0); ii<c.length (); ii++)
   octave_stdout << c (ii) << std::endl;

you would use exactly the same syntax to assign element values

ColumnVector d(c);
for (ii = octave_idx_type (0); ii<c.length (); ii++)
   d(c.length () - ii - 1) = c(ii);


For more on writing oct files see here:

http://www.gnu.org/software/octave/doc/interpreter/Oct_002dFiles.html#Oct_002dFiles

or here:

http://octave.sourceforge.net/coda/index.html

HTH,
c.





reply via email to

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