Re: Matrix Manipulation
- To: mathgroup at smc.vnet.net
- Subject: [mg16438] Re: Matrix Manipulation
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Sat, 13 Mar 1999 02:21:48 -0500
- References: <7c5bl0$7rt@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Andreas Paul Friedrich Bernhard wrote in message
<7c5bl0$7rt at smc.vnet.net>...
>
>I am trying to modify the elements of a submatrix in a matrix, without
>having to replace each element explicitly
>
>for example:
>mm = { {1,2,3}, {4,5,6}, {7,8,9} }
>msub = { {21,22}, {23,24} }
>I now wish to add the sub matrix: to positions (1,1),(1,3),(3,1),(3,3)
>
>I have tried using ReplacePart but it does not recognize the
>multidimensional replacement, I have also tried
>mm[ {{1,3} , {1,3}} ] = mm[ {{1,3} , {1,3}}] + msub
>
>but this crashes horribly
>
Andy:
mm = { {1,2,3}, {4,5,6}, {7,8,9} };
msub = { {21,22}, {23,24} };
mm[[{1,3},{1,3}]] =msub;mm
{{21,2,22},{4,5,6},{23,8,24}}
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565