[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Create Matrices e.g. A = randn(5,5,3) in .oct file
From: |
Carlo De Falco |
Subject: |
Re: Create Matrices e.g. A = randn(5,5,3) in .oct file |
Date: |
Fri, 3 Apr 2015 10:49:14 +0000 |
On 2 Apr 2015, at 23:40, babelproofreader <address@hidden> wrote:
> As part of an attempt to convert an Octave .m function to a .oct function I
> need to create an array of matrices, the typical Octave code for which looks
> like:-
>
> A = 0.01 * randn( 5 , 5 , 3 ) ;
>> which randn
'randn' is a built-in function from the file libinterp/corefcn/rand.cc
How to call a builtin function in an oct-file is documented here:
http://www.gnu.org/software/octave/doc/interpreter/Calling-Octave-Functions-from-Oct_002dFiles.html#Calling-Octave-Functions-from-Oct_002dFiles
but is not recomended.
>
> How would I code this in a .oct function? I'm even having problems with just
> declaring and creating a simple equivalent structure, e.g. Matrix A ( 5 , 5
> , 3 ) is only giving a single 5 by 5 matrix, not the three 5 by 5 matrices
> the octave code produces.
>
A Matrix with more than two indices is called an NDArray:
http://www.gnu.org/software/octave/doc/interpreter/Matrices-and-Arrays-in-Oct_002dFiles.html#Matrices-and-Arrays-in-Oct_002dFiles
HTH,
c.