help-octave
[Top][All Lists]
Advanced

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

Re: matrix with 3 indices


From: Yoel Callev
Subject: Re: matrix with 3 indices
Date: Tue, 16 Jul 2002 16:22:26 +0300
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2.1) Gecko/20010901


Yoel Callev wrote:


scherer wrote:

Dear Sir
I am using OCTAVE as a programming language in a course on computational

methos of Physics. At the moment I am teaching molecular dynamics: on a
rectangular
lattice of cells I need two indices to specify each cell and a third
index to enumerate
the atoms in the cell. In MATLAB I would simply create a matrix A with
elements
A(i, j, k), but this feature is apparently not suported by OCTAVE. Is
there an alternative?
Thanks for your answer.
Claudio Scherer

You can use cells: A{k}(i,j).
This way different cells (k's) can contain matrices of different sizes, and these matrices can still be multiplied.

You can allocate such arrays with cell(size), and read about it on the MATLAB help under 'cell arrays', athough I havn't found any reference in Octave's help file, this feature does exists in Octave

Apperantly this was a mistake, cells don't work in Octave yet, (or at least not in the MATLAB syntax), but there is a different quick & dirty solution - just use:

eval(sprintf("my_matrix%d(%d,%d)",k,i,j));

and work with matrices named my_matrix1,my_matrix2 etc.

  -Yoel Callev (femto.tau.ac.il/~yoel)





-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

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