From help-request at octave dot org Wed Jan 18 11:58:36 2006 Subject: Toy NDArray example From: Keith Goodman To: octave help mailing list Date: Wed, 18 Jan 2006 11:53:36 -0600 I'm trying, for the first time, to port a m-file to an oct-file. I got stuck on NDArrays. Are there any toy examples around that I can copy? All I can find are long functions that I cannot follow. Here's my own (unsuccessful) attempt at a toy NDArray example: #include DEFUN_DLD(ndarraytest, args, nargout, "I have no idea what I am doing.") { // input matrix x is 3D NDArray x = args(0).array_value(); // n3 is size(x,3). n3 = ???; // I would like to loop over the 3rd dimension of x for (int i=0; i < (n3-1); i++) { y(:,:,i) = inv(x(:,:,i)); } // Now return y octave_value_list retval; retval.append(y); return retval; } ------------------------------------------------------------- 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 -------------------------------------------------------------