[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
matrix subsetting
From: |
John W. Eaton |
Subject: |
matrix subsetting |
Date: |
Fri, 31 Mar 2000 02:54:54 -0600 (CST) |
On 30-Mar-2000, Heber Farnsworth <address@hidden> wrote:
| How does one do matrix subsetting in a dynamically loaded function (.oct
| file)? I know how to put a whole matrix into a certain place in a
| larger matrix using insert but I don't know how to do the reverse. I
| want to create a matrix out of part of an existing matrix. In an m-file
| you would write
|
| Y = X(a:b,c:d);
|
| Does anyone know how to do this?
Yes, but exactly how depends on what kinds of objects X, a, b, c, and
d are. If you have X as a Matrix object, and a, b, c, d are ints, you
can use
Matrix Matrix::extract (int r1, int c1, int r2, int c2) const;
(you'll need to adjust for the fact that Matrix objects use a 0-based
indexing).
jwe
-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.che.wisc.edu/octave/octave.html
How to fund new projects: http://www.che.wisc.edu/octave/funding.html
Subscription information: http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------