Re: Dynamic iterators in Do loop
- To: mathgroup at smc.vnet.net
- Subject: [mg66418] Re: Dynamic iterators in Do loop
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Thu, 11 May 2006 05:36:16 -0400 (EDT)
- Organization: The University of Western Australia
- References: <e3js6u$8jt$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <e3js6u$8jt$1 at smc.vnet.net>, sai <iwillfail at gmail.com>
wrote:
> I have an (n,n) matrix. I want to define an (m,m) matrix [m<n] whose elements
> are defined from the (n,n) matrix. The value of n and m changes from problem
> to problem. How can i do this in mathematica?
For an arbitrary matrix, say
mat[n_] := Table[a[i, j], {i,n},{j,n}]
then the easiest way to extract a block of the matrix is to use Part
with Range. For example,
mat[10][[ Range[2,5],Range[3,6] ]]
extracts a 4 x 4 submatrix from the 10 x 10 matrix.
Cheers,
Paul
_______________________________________________________________________
Paul Abbott Phone: 61 8 6488 2734
School of Physics, M013 Fax: +61 8 6488 1014
The University of Western Australia (CRICOS Provider No 00126G)
AUSTRALIA http://physics.uwa.edu.au/~paul